MouseEvents with JUNG and Java -


i made pluggablegraphmouse , 2 editinggraphmousepluggings in java jung program. if set modifiers left click , right click works fine, here setmodifiers code:

ovalmouse.setmodifiers(mouseevent.button1_mask); circlemouse.setmodifiers(mouseevent.button3_mask); 

what i'd have left click 1 thing , shift + left click (instead of right click) other. i've tried every combination can think of can't seem work. here of more logical combinations i've tried don't work:

//my logic here button1 , shift down doesn't work circlemouse.setmodifiers(mouseevent.button1_mask & mouseevent.shift_down_mask);  // logic here button1 , shift doesn't work either circlemouse.setmodifiers(mouseevent.button1_mask & mouseevent.shift_mask);  // tried inputevents didn't work either circlemouse.setmodifiers(inputevent.button1_down_mask & inputevent.shift_down_mask); 

if knows correct modifiers can use button 1 ovalmouse , button 1 + shift circlemouse please let me know. thanks.

to filter shift+button3 in jung2's xxxgraphmouseplugin mouse event implements mouselistener:

    system.out.println(circlemouse.getmodifiers());     if (( circlemouse.getmodifiers() & (mouseevent.shift_mask | mouseevent.button3_mask)) == (mouseevent.shift_mask | mouseevent.button3_mask)){         system.out.println(mouseevent.getmousemodifierstext(circlemouse.getmodifiers()));     } 

update

so, if want differentiate mouse event between button3 , shift+button3, following test show you:

graphmouse.add(new mypopupgraphmouseplugin());  protected class mypopupgraphmouseplugin extends abstractpopupgraphmouseplugin implements mouselistener {      @override     protected void handlepopup(mouseevent e) {         boolean filtered1 = false;         boolean filtered2 = false;          system.out.println(e.getmodifiers());         if (( e.getmodifiers() & (mouseevent.shift_mask | mouseevent.button3_mask)) == (mouseevent.shift_mask | mouseevent.button3_mask)){             filtered1 = true;         }         if (( e.getmodifiers() & (mouseevent.button3_mask)) == (mouseevent.button3_mask)){             filtered2 = true;         }          if(filtered2 == true) {             system.out.println("button3");         }         if(filtered1 == true) {             system.out.println("shift+button3");             //or more useful pop jpopupmenu         }            } } 

in above test under jung2:

  1. with shift key: pressing shift+button3 (shift key + right-click mouse button) show both "button3" , "shift+button3" messages

  2. except shift key: pressing any key + button3 (any key + right-click mouse button) show "button3" message


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -