Login  Register

Mouse Button Modifiers Lost In Newt mouseDragged Events

Posted by rhatcher on Oct 09, 2012; 9:35pm
URL: https://forum.jogamp.org/Mouse-Button-Modifiers-Lost-In-Newt-mouseDragged-Events-tp4026456.html

Fedora 12
JRE/JDK 7u7
GeForce 9800 GT + NVIDIA driver 304.37
JOGAMP/JOGL custom build from 10/09/2012 repos (RC11 in progress)

This probably should have gone straight to Bugzilla, but first I thought I'd see what the forum had to say:

I noticed today that newt events lose information about the mouse button state in at least some circumstances with JDK 7u7.  For example, if I left-click-and-drag with the mouse, when I dump out event.getModifiers() and event.getButton() they are both zero when the left mouse button is held.

The center and right buttons result in a non-zero getModifiers() value, but getButton() returns zero in those cases too in mouseDragged events.

The JDK7 AWT MouseEvent class appears to only set its "button" field for MOUSE_PRESSED, MOUSE_RELEASED, and MOUSE_CLICKED event ids.  The newt stuff bases the newt mouse event getButton() return value on the AWT event's getButton() result, so this might explain why getButton() returns zero in mouseDragged, and probably in mouseMoved events too though I haven't tried this yet.

The behavior of the getModifiers() return value is slightly trickier.  The button state is also in the modifiers for all three buttons.  In the AWT goo the middle and right mouse button masks are set to Event.ALT_MASK and Event.META_MASK respectively.  The AWTNewtEventFactory.awtModifiers2Newt method pays attention to ALT_MASK and EVENT_MASK, but not to BUTTON1_MASK.  The end result is that the middle and right mouse buttons make it through in the modifiers, but the left mouse button is lost.

Not sure what the "correct" behavior would be here.  It seems wrong that the AWT is not setting the button state for mouse event ids other than pressed/released/clicked unless there is some special meaning to the getButton() return value.  Could newt work around this by basing its button state on the AWT modifiers instead of the result of getButton()?