Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use MouseEvent.buttons for button state tracking #1921

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

CendioHalim
Copy link

@CendioHalim CendioHalim commented Nov 29, 2024

Instead of keeping track of button states ourselves by looking at MouseEvent.button, we can use the MouseEvent.buttons which already contains the state of all buttons.

Note that in MouseEvent.button, button numbers are mapped as follows:

0 -> Left
1 -> Middle
2 -> Right
3 -> Back
4 -> Forward

But when looking at the MouseEvent.buttons property, the bits middle and right are switched, which is confusing:

0 -> Left
1 -> Right
2 -> Middle
3 -> Back
4 -> Forward

With this change, #1919 could be modified to work with Safari as well.

Unfortunately, the internal _mouseButtonStateMask state is not removed in this PR as it would require a large rewrite of the general architecture.

Tested on:

  • Linux
    • Firefox
    • Chrome
    • Epiphany
  • Windows 11
    • Edge
    • Chrome
    • Firefox
  • macOS
    • Safari
    • Edge
    • Chrome
    • Firefox
  • iPad
    • Safari

Instead of keeping track of button states ourselves by looking at
MouseEvent.button, we can use the MouseEvent.buttons which already
contains the state of all buttons.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant