On Wed, 5 Jul 2023 03:07:01 GMT, Prasanta Sadhukhan <[email protected]>
wrote:
> If an EventHandler or EventFilter for a mouse button is attached to a scene
> within a JFXPanel and the **primary mouse button** is held, any mouse button
> click will create an event such that event.getButton().name() wrongly returns
> PRIMARY, even if the secondary or middle button was clicked.
> This is because `SwingEvents.mouseButtonToEmbedMouseButton()` overwrites the
> button name after checking the modifier value.
> For mouse click with primary button `mouseButtonToEmbedMouseButton` is first
> called with `BUTTON1 `and modifier `BUTTON1_DOWN_MASK `(ie 1024) and then
> when secondary button(ie right button is clicked)
> `mouseButtonToEmbedMouseButton` is called with `BUTTON3 `and modifier
> `BUTTON3_DOWN_MASK | BUTTON1_DOWN_MASK` (ie 5120)
> and when secondary button is released, `mouseButtonToEmbedMouseButton` is
> again called with `BUTTON3 `but with modifier `BUTTON1_DOWN_MASK `(1024)
> resulting in button being declared PRIMARY.
>
> Fix is to make sure not to overwrite button name if a button name is already
> assigned.
modules/javafx.swing/src/main/java/com/sun/javafx/embed/swing/SwingEvents.java
line 84:
> 82: }
> 83: // Fix for RT-15457: we should report mouse buttons for mouse
> drags
> 84: if (abstractButton == AbstractEvents.MOUSEEVENT_NONE_BUTTON) {
minor: the placement of the old comment suggests that it applies to like 84
(this change). Perhaps the comment should be moved down to the line 85.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1170#discussion_r1253538089