< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 214                 break;
 215             case CocoaConstants.NSMouseEntered:
 216                 jeventType = MouseEvent.MOUSE_ENTERED;
 217                 break;
 218             case CocoaConstants.NSMouseExited:
 219                 jeventType = MouseEvent.MOUSE_EXITED;
 220                 break;
 221             case CocoaConstants.NSScrollWheel:
 222                 jeventType = MouseEvent.MOUSE_WHEEL;
 223                 break;
 224             case CocoaConstants.NSKeyDown:
 225                 jeventType = KeyEvent.KEY_PRESSED;
 226                 break;
 227             case CocoaConstants.NSKeyUp:
 228                 jeventType = KeyEvent.KEY_RELEASED;
 229                 break;
 230         }
 231         return jeventType;
 232     }
 233 
 234     /*
 235      * Converts NSEvent mouse modifiers to AWT mouse modifiers.
 236      */
 237     static native int nsToJavaMouseModifiers(int buttonNumber,
 238                                                     int modifierFlags);
 239 
 240     /*
 241      * Converts NSEvent key modifiers to AWT key modifiers.
 242      */
 243     static native int nsToJavaKeyModifiers(int modifierFlags);
 244 
 245     /*
 246      * Converts NSEvent key info to AWT key info.
 247      */
 248     static native boolean nsToJavaKeyInfo(int[] in, int[] out);
 249 
 250     /*
 251      * Converts NSEvent key modifiers to AWT key info.
 252      */
 253     static native void nsKeyModifiersToJavaKeyInfo(int[] in, int[] out);
 254 
 255     /*
 256      * There is a small number of NS characters that need to be converted
 257      * into other characters before we pass them to AWT.
 258      */
 259     static native char nsToJavaChar(char nsChar, int modifierFlags);
 260 
 261     static boolean isPopupTrigger(int jmodifiers) {
 262         final boolean isRightButtonDown = ((jmodifiers & InputEvent.BUTTON3_DOWN_MASK) != 0);
 263         final boolean isLeftButtonDown = ((jmodifiers & InputEvent.BUTTON1_DOWN_MASK) != 0);
   1 /*
   2  * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 214                 break;
 215             case CocoaConstants.NSMouseEntered:
 216                 jeventType = MouseEvent.MOUSE_ENTERED;
 217                 break;
 218             case CocoaConstants.NSMouseExited:
 219                 jeventType = MouseEvent.MOUSE_EXITED;
 220                 break;
 221             case CocoaConstants.NSScrollWheel:
 222                 jeventType = MouseEvent.MOUSE_WHEEL;
 223                 break;
 224             case CocoaConstants.NSKeyDown:
 225                 jeventType = KeyEvent.KEY_PRESSED;
 226                 break;
 227             case CocoaConstants.NSKeyUp:
 228                 jeventType = KeyEvent.KEY_RELEASED;
 229                 break;
 230         }
 231         return jeventType;
 232     }
 233 
 234     /**
 235      * Converts NSEvent key modifiers to AWT key modifiers. Note that this
 236      * method adds the current mouse state as a mouse modifiers.
 237      *
 238      * @param  modifierFlags the NSEvent key modifiers
 239      * @return the java key and mouse modifiers


 240      */
 241     static native int nsToJavaModifiers(int modifierFlags);
 242 
 243     /*
 244      * Converts NSEvent key info to AWT key info.
 245      */
 246     static native boolean nsToJavaKeyInfo(int[] in, int[] out);
 247 
 248     /*
 249      * Converts NSEvent key modifiers to AWT key info.
 250      */
 251     static native void nsKeyModifiersToJavaKeyInfo(int[] in, int[] out);
 252 
 253     /*
 254      * There is a small number of NS characters that need to be converted
 255      * into other characters before we pass them to AWT.
 256      */
 257     static native char nsToJavaChar(char nsChar, int modifierFlags);
 258 
 259     static boolean isPopupTrigger(int jmodifiers) {
 260         final boolean isRightButtonDown = ((jmodifiers & InputEvent.BUTTON3_DOWN_MASK) != 0);
 261         final boolean isLeftButtonDown = ((jmodifiers & InputEvent.BUTTON1_DOWN_MASK) != 0);
< prev index next >