Normally to retrieve the value of the mouse wheel, I just read
mouseEvent.getRotation()[1] But why if shift is pressed, that value is found at mouseEvent.getRotation()[0] ? |
Administrator
|
If you press Shift, the operating system treats your scroll as an horizontal one, not a vertical one. Please look at the documentation:
http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/newt/event/MouseEvent.html#getRotation()
Julien Gouesse | Personal blog | Website
|
Ok, merci bocu
|
This post was updated on .
Ah, and what about if I need to check a double combination?
For example if both MouseEvent.BUTTON1 && MouseEvent.BUTTON2 are pressed at the same time? Sorry, is it right doing so? if ((mouseEvent.getModifiers() & (MouseEvent.BUTTON2_MASK + MouseEvent.BUTTON3_MASK)) == (MouseEvent.BUTTON2_MASK | MouseEvent.BUTTON3_MASK)) { ... } |
Administrator
|
This post was updated on .
Hi
Maybe it would be easier to implement with getButtonsDown(). Edit.: Moreover, wheres AWT has 2 methods returning modifiers (getModifiers() for the states that have just changed, getModifiersEx() with all states), NEWT only has a single getModifiers() method. Don't use +, rather use BUTTON1_DOWN_MASK | BUTTON2_DOWN_MASK but it won't work if NEWT getModifiers() behaves exactly like AWT getModifiers(). In Ardor3D, I only use MouseEvent.getButton(). When you press a mouse button, a new mouse event is generated. If you press the mouse button 1 and then the mouse button 2, 2 mouse (pressed) events are generated. In an high level input system, the current state should already contain the first pressed button when you press the second one.
Julien Gouesse | Personal blog | Website
|
This post was updated on .
Exactly, this is the result of me.getModifiers() press B1 32 press B2 160 release B1 160 press B1 160 This is a pity, why Newt doesn't have both getModifiers() and me.getModifiersEx()? I will try to use getButtonsDown()[] and MouseEvent.BUTTONx instead. It seems it puts the pressed buttons always in increasing order Edit: the mouseWheelMoved returns 1 as well buttons[0] = 1 This is wrong or? Shouldn't it the BUTTON1? Edit2: if I just scroll the wheel or if I press and hold B1 and then scroll the wheel, this public void mouseWheelMoved(MouseEvent me) { System.out.println("mouseWheelMoved"); System.out.println(me.getModifiers()+" "+me.getButton()+" "+me.getRotation()[1]); for(int i=0; i<me.getButtonsDown().length;i++){ System.out.println("buttons["+i+"] = "+me.getButtonsDown()[i]); }</i> is returning exactly the same input.. mouseWheelMoved 32 1 1.0 buttons[0] = 1 This is a kind of problem for me, because we would like to have a generic mouseListener, that is if the use wanna change a mouse combination he can.. And if I get the same output I need to modify the mousePressed/Released and make it hardcoded.. |
Administrator
|
There is something wrong with getButtonsDown(), the result doesn't match with the documentation.
I think that most of the problem doesn't come from NEWT, AWT already works very similarly except that it has a getModifiersEx() method but it's not necessary. TUER uses the JOGL NEWT backend of Ardor3D and it allows to modify the combination of keys, you can get the correct behaviour without getModifiersEx() by storing and managing the mouse states in the same way Ardor3D does.
Julien Gouesse | Personal blog | Website
|
You mean here https://github.com/Renanse/Ardor3D/blob/master/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtMouseWrapper.java ? |
Administrator
|
Yes. That's why we create high level libraries, it allows developers to keep concentrated on their softwares, they don't have to write this kind of code themselves. When the mouse state is already set in mousePressed, you can see that the buttons states are simply updated. After the update, this state reflects the fact that 2 buttons are pressed, it seems to be what you want.
Julien Gouesse | Personal blog | Website
|
Free forum by Nabble | Edit this page |