Login  Register

Re: Mouse Button Modifiers Lost In Newt mouseDragged Events

Posted by Sven Gothel on Oct 10, 2012; 7:31am
URL: https://forum.jogamp.org/Mouse-Button-Modifiers-Lost-In-Newt-mouseDragged-Events-tp4026456p4026461.html

On 10/09/2012 11:35 PM, rhatcher [via jogamp] wrote:

> 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.  
Your post is a bit confusing, since it is not clear 'from the top'
which module you are referring here. I guess mentioning JDK7 is the culprit
here or the fact that I just woke up :)

NEWT [X11, Win, OSX, ..], SWT, AWT, ... who knows ?

> 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.
>
I assume NEWT ?
If so .. have you digged into the source code and checked?
Understand this as a kudos to you, i.e. familiar w/ our stuff so maybe
beginning to read the source and becoming a patch contributor via git
would be something desired (for me). Then .. it's still early in the morning
and hopefully you are enjoying my entertainment :)

> The center and right buttons result in a non-zero getModifiers() value, but
> getButton() returns zero in those cases too in mouseDragged events.
Realizing that our NEWT UI test framework is truly crap, i.e.
self written AWT robot methods performing too simple and not so reliable
actions and their validation.
Expanding this to test mouse actions might be a challenge.

>
> 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.
We are talking NewtCanvasAWT here ? I finally get a clue .. :)

>
> 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.
Nice, seems like you found a bug.
Would you be so kind and maybe fix it ?
Looks like you already validated the source code (KUDOS),
so a fix might be easy for you now.

>
> Not sure what the "correct" behavior would be here.  
I hate AWT :)

> 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()?

Policy is, as you feel as well, to provide all information in a reasonable
way w/o jumping through hoops.

Since you are already on this matter, pls file a bug report
assign it to yourself and fix it. I will help & assiste ofc.

I am very happy that we have such a huge feedback already,
which helps stabilizing and fixing bugs as well as enhancing stuff.

If we could come to the point that we have more source code contributors,
people who are also willing to patch and fix bugs and to provide unit tests
so their work is being seen via our glorious Jenkins receiving some Chuck'les,
 .. well .. that would be even more awesome :)

So .. I hope you all read this with lots of humor, it's not meant to be mean,
on the contrary - KUDOS.
Just me begging to move on to the next level, kicking my behind to
review your commits. Maybe somebody will even review my boring elaborations
and criticizes it, constructively of course :)

Wish you a great Wednesday and good morning!

~Sven



signature.asc (907 bytes) Download Attachment