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
8242419: JFXPanel: MouseEvent always reports that Primary button changed state if held #1170
Conversation
…ged state if held
👋 Welcome back psadhukhan! A progress list of the required criteria for merging this PR into |
…ged state if held
Webrevs
|
modules/javafx.swing/src/main/java/com/sun/javafx/embed/swing/SwingEvents.java
Show resolved
Hide resolved
Any further comments on this @andy-goryachev-oracle ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modified the code test thusly:
scene.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> System.out.println("Button clicked: " + event.getButton().name()));
scene.addEventHandler(MouseEvent.MOUSE_PRESSED, event -> System.out.println("Button pressed: " + event.getButton().name()));
scene.addEventHandler(MouseEvent.MOUSE_RELEASED, event -> System.out.println("Button released: " + event.getButton().name()));
tested with the fix (works as expected) and without the fix (fails as expected).
@prsadhuk This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 101 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
/integrate |
Going to push as commit 8635f81.
Your commit was automatically rebased without conflicts. |
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 withBUTTON1
and modifierBUTTON1_DOWN_MASK
(ie 1024) and then when secondary button(ie right button is clicked)mouseButtonToEmbedMouseButton
is called withBUTTON3
and modifierBUTTON3_DOWN_MASK | BUTTON1_DOWN_MASK
(ie 5120)and when secondary button is released,
mouseButtonToEmbedMouseButton
is again called withBUTTON3
but with modifierBUTTON1_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.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1170/head:pull/1170
$ git checkout pull/1170
Update a local copy of the PR:
$ git checkout pull/1170
$ git pull https://git.openjdk.org/jfx.git pull/1170/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1170
View PR using the GUI difftool:
$ git pr show -t 1170
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1170.diff
Webrev
Link to Webrev Comment