fokoid/chipper8

mouse clicks on keypad buttons don't get highlighted

Opened this issue · 1 comments

  • the keypad window keys are supposed to highlight when the relevant input is being triggered
  • this works for actual keyboard input
  • it does not currently work for mouseclicks on the buttons
  • this is due to the way immediate mode works
    • in particular, we don't know if the button is clicked until after we draw it so the highlighting decision is based on state from previous frame
    • however, the key press state is reset at the start of each frame based on the keyboard
    • thus clicks never get a chance to cause highlighting
    • they do get detected correctly as key inputs to the VM, though

a few ideas to fix

  • keep separate state inside the keypad window to track the button click status and keep this in sync somehow with the key capture state (ugly)
  • create our own keypad widget (harder but nicer solution). widget would do the following in order:
  1. allocates the entire rect
  2. detects mouse down and maps to the correct key based on pointer coordinates
  3. finally draws the visuals including the highlight based on the current frame