You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Description
This PR simplifies logic that handles `mouseButton` property. I've changed `event.button` to `event.buttons`. These values now correctly align with our `MouseButton` enum, so `Map` is no longer necessary.
| Button | `event.button` | `MouseButton` | `event.buttons` |
|--------|--------------|-------------|---------------|
| Left | 0 | 1 | 1 |
| Right | 2 | 2 | 2 |
| Middle | 1 | 4 | 4 |
| Btn_4 | 3 | 8 | 8 |
| Btn_5 | 4 | 16 | 16 |
You can find values in MDN docs for:
- `event.button` [here](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button#value)
- `event.buttons` [here](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons#value)
> [!NOTE]
> `event.buttons` also performs logical `or` operation on buttons, so for example using both **left** and **right** buttons at the same time results in value of `3`.
> [!IMPORTANT]
> I've tested behavior when trying to activate handler with different buttons. In case where handler has `mouseButton(MouseButton.LEFT)` clicking first with left button, then adding other button results in activation. This is fine and aligns with what we have now. Clicking with other button and then adding left button does not result in activation. This is also fine.
>
> Now, clicking with both buttons at the same time does not result in activation. This is because in that case there's no `pointerdown` event. Turns out that `pointerdown` is called only for the first button, all the other pointers result in `pointermove` event. In case where both are pressed at the same time, there's only `pointermove` event.
## Test plan
Tested on **MouseButtons** example
0 commit comments