I made a PluggableGraphMouse and 2 EditingGraphMousePluggings in my Java with JUNG program. If I set the modifiers to be left click and right click it works perfectly fine, here is the setModifiers code:
ovalMouse.setModifiers(MouseEvent.BUTTON1_MASK);
circleMouse.setModifiers(MouseEvent.BUTTON3_MASK);
What I'd like however is to have left click do one thing and SHIFT + left click (instead of right click) do the other. I've tried every combination I can think of but I can't seem to get it to work. Here are some of the more logical combinations I've tried that don't work:
//My logic here is Button1 AND Shift is down but this doesn't work
circleMouse.setModifiers(MouseEvent.BUTTON1_MASK & MouseEvent.SHIFT_DOWN_MASK);
// My logic here is Button1 AND Shift but this doesn't work either
circleMouse.setModifiers(MouseEvent.BUTTON1_MASK & MouseEvent.SHIFT_MASK);
// Also tried InputEvents but those didn't work either
circleMouse.setModifiers(InputEvent.BUTTON1_DOWN_MASK & InputEvent.SHIFT_DOWN_MASK);
If anyone knows what the correct modifiers are so I can use button 1 for ovalMouse and button 1 + shift for circleMouse please let me know. Thanks.
To filter Shift+Button3 in any
JUNG2
's xxxGraphMousePlugin mouse event that implementsMouseListener
:Update
So, if you want to differentiate a mouse event between
BUTTON3
andSHIFT+BUTTON3
, the following test will show you:In the above test under
JUNG2
:With the SHIFT key: pressing
SHIFT+BUTTON3
(SHIFT key + right-click mouse button) will show both "BUTTON3" and "SHIFT+BUTTON3" messagesExcept the SHIFT key: pressing
any key + BUTTON3
(any key + right-click mouse button) will only show "BUTTON3" message