Skip to content

Mouse pointer moves to centre of canvas on click in OpenGL3 with Swing #2327

@terranprog

Description

@terranprog

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:

  1. Use JME 3.7.0-stable
  2. Be running OpenGL3
  3. Have a jme canvas embedded in a swing window
  4. Listen for jme mouse events using InputManager.addListener(ActionListener)
  5. Left click on the canvas
  6. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions