fluid-lab / gamepad-navigator

GSoC 2020 project
Other
6 stars 10 forks source link

Make click action fire three mouse events. #91

Closed duhrer closed 4 months ago

duhrer commented 2 years ago

Currently, the "click" action triggers the "click" function directly on the focused (non-select) target element. This has a couple of key limitations:

  1. There is no on-screen indication that a button is clicked or released.
  2. Any "click" listener that tries to call event.preventDefault will fail.

It would be better to dispatch a "mousedown" and "click" even when the button is pressed, and to dispatch a "mouseup" even when the button is released.

duhrer commented 2 years ago

With the changes here, a button click behaves much more like a mouse click, and no test changes were needed.

duhrer commented 2 years ago

I think we need to add a better test suite for clicks, I tried this with something like Weavly, the mouse events didn't make it through.

duhrer commented 2 years ago

The previous approach (triggering the click function instead of dispatching a click event) does work, I may revert just that call.

duhrer commented 4 months ago

We have long converted to using the click function for everything, and given that we don't really do anything on button release, there doesn't seem to be much point in simulating all three events unless we have a good example of an element that requires it.