< prev index next >

src/java.desktop/macosx/classes/sun/lwawt/macosx/CTrayIcon.java

Print this page




 197     }
 198 
 199     //invocation from the AWTTrayIcon.m
 200     private void handleMouseEvent(NSEvent nsEvent) {
 201         int buttonNumber = nsEvent.getButtonNumber();
 202         final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
 203         if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled())
 204                 || buttonNumber > tk.getNumberOfButtons() - 1) {
 205             return;
 206         }
 207 
 208         int jeventType = NSEvent.nsToJavaEventType(nsEvent.getType());
 209 
 210         int jbuttonNumber = MouseEvent.NOBUTTON;
 211         int jclickCount = 0;
 212         if (jeventType != MouseEvent.MOUSE_MOVED) {
 213             jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber);
 214             jclickCount = nsEvent.getClickCount();
 215         }
 216 
 217         int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber,
 218                 nsEvent.getModifierFlags());
 219         boolean isPopupTrigger = NSEvent.isPopupTrigger(jmodifiers);
 220 
 221         int eventButtonMask = (jbuttonNumber > 0)?
 222                 MouseEvent.getMaskForButton(jbuttonNumber) : 0;
 223         long when = System.currentTimeMillis();
 224 
 225         if (jeventType == MouseEvent.MOUSE_PRESSED) {
 226             mouseClickButtons |= eventButtonMask;
 227         } else if (jeventType == MouseEvent.MOUSE_DRAGGED) {
 228             mouseClickButtons = 0;
 229         }
 230 
 231         // The MouseEvent's coordinates are relative to screen
 232         int absX = nsEvent.getAbsX();
 233         int absY = nsEvent.getAbsY();
 234 
 235         MouseEvent mouseEvent = new MouseEvent(dummyFrame, jeventType, when,
 236                 jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger,
 237                 jbuttonNumber);




 197     }
 198 
 199     //invocation from the AWTTrayIcon.m
 200     private void handleMouseEvent(NSEvent nsEvent) {
 201         int buttonNumber = nsEvent.getButtonNumber();
 202         final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
 203         if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled())
 204                 || buttonNumber > tk.getNumberOfButtons() - 1) {
 205             return;
 206         }
 207 
 208         int jeventType = NSEvent.nsToJavaEventType(nsEvent.getType());
 209 
 210         int jbuttonNumber = MouseEvent.NOBUTTON;
 211         int jclickCount = 0;
 212         if (jeventType != MouseEvent.MOUSE_MOVED) {
 213             jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber);
 214             jclickCount = nsEvent.getClickCount();
 215         }
 216 
 217         int jmodifiers = NSEvent.nsToJavaModifiers(
 218                 nsEvent.getModifierFlags());
 219         boolean isPopupTrigger = NSEvent.isPopupTrigger(jmodifiers);
 220 
 221         int eventButtonMask = (jbuttonNumber > 0)?
 222                 MouseEvent.getMaskForButton(jbuttonNumber) : 0;
 223         long when = System.currentTimeMillis();
 224 
 225         if (jeventType == MouseEvent.MOUSE_PRESSED) {
 226             mouseClickButtons |= eventButtonMask;
 227         } else if (jeventType == MouseEvent.MOUSE_DRAGGED) {
 228             mouseClickButtons = 0;
 229         }
 230 
 231         // The MouseEvent's coordinates are relative to screen
 232         int absX = nsEvent.getAbsX();
 233         int absY = nsEvent.getAbsY();
 234 
 235         MouseEvent mouseEvent = new MouseEvent(dummyFrame, jeventType, when,
 236                 jmodifiers, absX, absY, absX, absY, jclickCount, isPopupTrigger,
 237                 jbuttonNumber);


< prev index next >