< prev index next >

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

Print this page




  58         final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
  59         if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled())
  60                 || buttonNumber > tk.getNumberOfButtons() - 1) {
  61             return;
  62         }
  63 
  64         int jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) :
  65                                            NSEvent.nsToJavaEventType(eventType);
  66 
  67         int jbuttonNumber = MouseEvent.NOBUTTON;
  68         int jclickCount = 0;
  69 
  70         if (jeventType != MouseEvent.MOUSE_MOVED &&
  71             jeventType != MouseEvent.MOUSE_ENTERED &&
  72             jeventType != MouseEvent.MOUSE_EXITED)
  73         {
  74             jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber);
  75             jclickCount = clickCount;
  76         }
  77 
  78         int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber,
  79                                                         modifierFlags);
  80         boolean jpopupTrigger = NSEvent.isPopupTrigger(jmodifiers);
  81 
  82         eventNotifier.notifyMouseEvent(jeventType, System.currentTimeMillis(), jbuttonNumber,
  83                 x, y, absX, absY, jmodifiers, jclickCount,
  84                 jpopupTrigger, null);
  85     }
  86 
  87     /**
  88      * Handles scroll events.
  89      */
  90     void handleScrollEvent(final int x, final int y, final int absX,
  91                            final int absY, final int modifierFlags,
  92                            final double deltaX, final double deltaY) {
  93         final int buttonNumber = CocoaConstants.kCGMouseButtonCenter;
  94         int jmodifiers = NSEvent.nsToJavaMouseModifiers(buttonNumber,
  95                                                         modifierFlags);
  96         final boolean isShift = (jmodifiers & InputEvent.SHIFT_DOWN_MASK) != 0;
  97 
  98         // Vertical scroll.
  99         if (!isShift && deltaY != 0.0) {
 100             dispatchScrollEvent(x, y, absX, absY, jmodifiers, deltaY);
 101         }
 102         // Horizontal scroll or shirt+vertical scroll.
 103         final double delta = isShift && deltaY != 0.0 ? deltaY : deltaX;
 104         if (delta != 0.0) {
 105             jmodifiers |= InputEvent.SHIFT_DOWN_MASK;
 106             dispatchScrollEvent(x, y, absX, absY, jmodifiers, delta);
 107         }
 108     }
 109 
 110     private void dispatchScrollEvent(final int x, final int y, final int absX,
 111                                      final int absY, final int modifiers,
 112                                      final double delta) {
 113         final long when = System.currentTimeMillis();
 114         final int scrollType = MouseWheelEvent.WHEEL_UNIT_SCROLL;
 115         final int scrollAmount = 1;


 170                 testChar = (char) out[2];
 171                 if(testChar == 0){
 172                     return;
 173                 }
 174             }
 175 
 176             jkeyCode = out[0];
 177             jkeyLocation = out[1];
 178             jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) :
 179                                            NSEvent.nsToJavaEventType(eventType);
 180         }
 181 
 182         char javaChar = NSEvent.nsToJavaChar(testChar, modifierFlags);
 183         // Some keys may generate a KEY_TYPED, but we can't determine
 184         // what that character is. That's likely a bug, but for now we
 185         // just check for CHAR_UNDEFINED.
 186         if (javaChar == KeyEvent.CHAR_UNDEFINED) {
 187             postsTyped = false;
 188         }
 189 
 190 
 191         int jmodifiers = NSEvent.nsToJavaKeyModifiers(modifierFlags);
 192         long when = System.currentTimeMillis();
 193 
 194         if (jeventType == KeyEvent.KEY_PRESSED) {
 195             lastKeyPressCode = jkeyCode;
 196         }
 197         eventNotifier.notifyKeyEvent(jeventType, when, jmodifiers,
 198                 jkeyCode, javaChar, jkeyLocation);
 199 
 200         // Current browser may be sending input events, so don't
 201         // post the KEY_TYPED here.
 202         postsTyped &= needsKeyTyped;
 203 
 204         // That's the reaction on the PRESSED (not RELEASED) event as it comes to
 205         // appear in MacOSX.
 206         // Modifier keys (shift, etc) don't want to send TYPED events.
 207         // On the other hand we don't want to generate keyTyped events
 208         // for clipboard related shortcuts like Meta + [CVX]
 209         if (jeventType == KeyEvent.KEY_PRESSED && postsTyped &&
 210                 (jmodifiers & KeyEvent.META_DOWN_MASK) == 0) {
 211             // Enter and Space keys finish the input method processing,




  58         final SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
  59         if ((buttonNumber > 2 && !tk.areExtraMouseButtonsEnabled())
  60                 || buttonNumber > tk.getNumberOfButtons() - 1) {
  61             return;
  62         }
  63 
  64         int jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) :
  65                                            NSEvent.nsToJavaEventType(eventType);
  66 
  67         int jbuttonNumber = MouseEvent.NOBUTTON;
  68         int jclickCount = 0;
  69 
  70         if (jeventType != MouseEvent.MOUSE_MOVED &&
  71             jeventType != MouseEvent.MOUSE_ENTERED &&
  72             jeventType != MouseEvent.MOUSE_EXITED)
  73         {
  74             jbuttonNumber = NSEvent.nsToJavaButton(buttonNumber);
  75             jclickCount = clickCount;
  76         }
  77 
  78         int jmodifiers = NSEvent.nsToJavaModifiers(modifierFlags);

  79         boolean jpopupTrigger = NSEvent.isPopupTrigger(jmodifiers);
  80 
  81         eventNotifier.notifyMouseEvent(jeventType, System.currentTimeMillis(), jbuttonNumber,
  82                 x, y, absX, absY, jmodifiers, jclickCount,
  83                 jpopupTrigger, null);
  84     }
  85 
  86     /**
  87      * Handles scroll events.
  88      */
  89     void handleScrollEvent(final int x, final int y, final int absX,
  90                            final int absY, final int modifierFlags,
  91                            final double deltaX, final double deltaY) {
  92         int jmodifiers = NSEvent.nsToJavaModifiers(modifierFlags);


  93         final boolean isShift = (jmodifiers & InputEvent.SHIFT_DOWN_MASK) != 0;
  94 
  95         // Vertical scroll.
  96         if (!isShift && deltaY != 0.0) {
  97             dispatchScrollEvent(x, y, absX, absY, jmodifiers, deltaY);
  98         }
  99         // Horizontal scroll or shirt+vertical scroll.
 100         final double delta = isShift && deltaY != 0.0 ? deltaY : deltaX;
 101         if (delta != 0.0) {
 102             jmodifiers |= InputEvent.SHIFT_DOWN_MASK;
 103             dispatchScrollEvent(x, y, absX, absY, jmodifiers, delta);
 104         }
 105     }
 106 
 107     private void dispatchScrollEvent(final int x, final int y, final int absX,
 108                                      final int absY, final int modifiers,
 109                                      final double delta) {
 110         final long when = System.currentTimeMillis();
 111         final int scrollType = MouseWheelEvent.WHEEL_UNIT_SCROLL;
 112         final int scrollAmount = 1;


 167                 testChar = (char) out[2];
 168                 if(testChar == 0){
 169                     return;
 170                 }
 171             }
 172 
 173             jkeyCode = out[0];
 174             jkeyLocation = out[1];
 175             jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) :
 176                                            NSEvent.nsToJavaEventType(eventType);
 177         }
 178 
 179         char javaChar = NSEvent.nsToJavaChar(testChar, modifierFlags);
 180         // Some keys may generate a KEY_TYPED, but we can't determine
 181         // what that character is. That's likely a bug, but for now we
 182         // just check for CHAR_UNDEFINED.
 183         if (javaChar == KeyEvent.CHAR_UNDEFINED) {
 184             postsTyped = false;
 185         }
 186 
 187         int jmodifiers = NSEvent.nsToJavaModifiers(modifierFlags);

 188         long when = System.currentTimeMillis();
 189 
 190         if (jeventType == KeyEvent.KEY_PRESSED) {
 191             lastKeyPressCode = jkeyCode;
 192         }
 193         eventNotifier.notifyKeyEvent(jeventType, when, jmodifiers,
 194                 jkeyCode, javaChar, jkeyLocation);
 195 
 196         // Current browser may be sending input events, so don't
 197         // post the KEY_TYPED here.
 198         postsTyped &= needsKeyTyped;
 199 
 200         // That's the reaction on the PRESSED (not RELEASED) event as it comes to
 201         // appear in MacOSX.
 202         // Modifier keys (shift, etc) don't want to send TYPED events.
 203         // On the other hand we don't want to generate keyTyped events
 204         // for clipboard related shortcuts like Meta + [CVX]
 205         if (jeventType == KeyEvent.KEY_PRESSED && postsTyped &&
 206                 (jmodifiers & KeyEvent.META_DOWN_MASK) == 0) {
 207             // Enter and Space keys finish the input method processing,


< prev index next >