1 19 20 package org.netbeans.modules.applemenu; 21 22 import java.awt.AWTEvent ; 23 import java.awt.event.AWTEventListener ; 24 import java.awt.event.InputEvent ; 25 import java.awt.event.MouseEvent ; 26 import java.lang.reflect.Field ; 27 import java.lang.reflect.Method ; 28 29 34 public class CtrlClickHack implements AWTEventListener { 35 36 37 public CtrlClickHack() { 38 } 39 40 public void eventDispatched(AWTEvent e) { 41 if (! (e instanceof MouseEvent )) { 42 return; 43 } 44 MouseEvent evt = (MouseEvent ) e; 45 if (evt.getModifiers() != (InputEvent.BUTTON1_MASK | InputEvent.CTRL_MASK)) { 46 return; 47 } 48 try { 49 Field f1 = InputEvent .class.getDeclaredField("modifiers"); 50 Field f2 = MouseEvent .class.getDeclaredField("button"); 51 Method m = MouseEvent .class.getDeclaredMethod("setNewModifiers", new Class [] {}); 52 f1.setAccessible(true); 53 f1.setInt(evt, InputEvent.BUTTON3_MASK); 54 f2.setAccessible(true); 55 f2.setInt(evt, MouseEvent.BUTTON3); 56 m.setAccessible(true); 57 m.invoke(evt, new Object [] {}); 58 } catch (Exception ex) { 59 ex.printStackTrace(); 60 } 61 } 62 63 } 64 | Popular Tags |