Simple monitor for displaying MIDI status for digital pianos.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

19 line
554 B

  1. import * as React from 'react'
  2. export const useForm = () => {
  3. const handleAction: React.FormEventHandler<HTMLElementTagNameMap['form']> = (e) => {
  4. e.preventDefault()
  5. const { submitter } = e.nativeEvent as unknown as { submitter: HTMLElementTagNameMap['button'] }
  6. if (submitter.name !== 'action') {
  7. return
  8. }
  9. const formValue = new FormData(e.currentTarget)
  10. const values = Object.fromEntries(formValue.entries())
  11. window.electron.ipcRenderer.send('action', submitter.value, values)
  12. }
  13. return {
  14. handleAction
  15. }
  16. }