Mouse pointer moves to centre of canvas on click in OpenGL3 with Swing
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start by reproducing the issue with JME 3.7.0-stable, an OpenGL3 canvas embedded in Swing, and an InputManager.addListener(ActionListener) handler. Compare InputManager.getCursorPosition() during mouseDown and mouseUp, then investigate the OpenGL3 Swing canvas input path against the OpenGL2 behavior. Done means the cursor remains at its physical position and both events report the expected coordinates without the Robot workaround.
Written by the indexing model from the issue text.
Description
With JME3.7 we can now embed OpenGL3 canvas in a Swing window. I have noticed an issue with the mouse with this configuration.
Steps to reproduce:
- Use JME 3.7.0-stable
- Be running OpenGL3
- Have a jme canvas embedded in a swing window
- Listen for jme mouse events using InputManager.addListener(ActionListener)
- Left click on the canvas
- In the ActionListener, get the position of the mouse using InputManager.getCursorPosition()
Observed
The mouseDown (i.e. keyPressed=true) will have the correct mouse position.
By the time the mouseUp event is processed (i.e. keyPressed=false), the position of the mouse has been moved to the centre of the canvas.
- The mouse is physically displayed in the centre of the canvas
- InputManager.getCursorPosition() will return a mouse position in the centre of the canvas
Notes:
- This does not happen if you are not using Swing
- This does not happen in OpenGL2 with Swing
- Seen on both Windows 10 and current Debian linux stable (12.7)
A workaround (more a hack) is to
- Store the location of the mousedown event
- In the mouseup event, use java.awt.Robot to move the mouse back to where the mousedown event happened.
- Dominant language
- Java
- Stars
- 4.3k
- Forks
- 1.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 23
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from jMonkeyEngine/jmonkeyengine
-
Documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
jMonkeyEngine/jmonkeyengine#2928 · 4 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
jMonkeyEngine/jmonkeyengine#2919 · 1 comment ·
Maintainers usually reply within 1 day
-
defect
Difficulty 1/5 Under an hour Newbie friendliness 88/100
jMonkeyEngine/jmonkeyengine#2717 ·
Maintainers usually reply within 1 day
-
Documentation
Difficulty 3/5 1-2 days Newbie friendliness 55/100
jMonkeyEngine/jmonkeyengine#2931 · 1 comment ·
Maintainers usually reply within 1 day
-
Documentation
Difficulty 3/5 1-2 days Newbie friendliness 57/100
jMonkeyEngine/jmonkeyengine#2930 · 3 comments ·
Maintainers usually reply within 1 day
All issues in jMonkeyEngine/jmonkeyengine
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
apache/rocketmq-dashboard#5358 ·
Maintainers usually reply within 3 days
-
area:cpan-port area:database bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
fglock/PerlOnJava#1605 ·
Maintainers usually reply within 1 day
-
1.0.0-rc2
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
wso2/dpdp-accelerator#377 ·
Maintainers usually reply within 1 day
-
area/dependencies backport/26.4 kind/cve severity/high source/scan-dependencies status/triage
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day