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

Print this page




 141             jeventType = out[2];
 142         } else {
 143             if (chars != null && chars.length() > 0) {
 144                 testChar = chars.charAt(0);
 145             }
 146 
 147             int[] in = new int[] {testChar, testDeadChar, modifierFlags, keyCode};
 148             int[] out = new int[2]; // [jkeyCode, jkeyLocation]
 149 
 150             postsTyped = NSEvent.nsToJavaKeyInfo(in, out);
 151             if (!postsTyped) {
 152                 testChar = KeyEvent.CHAR_UNDEFINED;
 153             }
 154 
 155             jkeyCode = out[0];
 156             jkeyLocation = out[1];
 157             jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) :
 158                                            NSEvent.nsToJavaEventType(eventType);
 159         }
 160 









 161         int jmodifiers = NSEvent.nsToJavaKeyModifiers(modifierFlags);
 162         long when = System.currentTimeMillis();
 163 
 164         peer.dispatchKeyEvent(jeventType, when, jmodifiers,
 165                               jkeyCode, testChar, jkeyLocation);
 166 
 167         // That's the reaction on the PRESSED (not RELEASED) event as it comes to
 168         // appear in MacOSX.
 169         // Modifier keys (shift, etc) don't want to send TYPED events.
 170         // On the other hand we don't want to generate keyTyped events
 171         // for clipboard related shortcuts like Meta + [CVX]
 172         boolean isMetaDown = (jmodifiers & KeyEvent.META_DOWN_MASK) != 0;
 173         if (jeventType == KeyEvent.KEY_PRESSED && postsTyped && !isMetaDown) {
 174             peer.dispatchKeyEvent(KeyEvent.KEY_TYPED, when, jmodifiers,
 175                                   KeyEvent.VK_UNDEFINED, testChar,
 176                                   KeyEvent.KEY_LOCATION_UNKNOWN);
 177         }
 178     }
 179 }


 141             jeventType = out[2];
 142         } else {
 143             if (chars != null && chars.length() > 0) {
 144                 testChar = chars.charAt(0);
 145             }
 146 
 147             int[] in = new int[] {testChar, testDeadChar, modifierFlags, keyCode};
 148             int[] out = new int[2]; // [jkeyCode, jkeyLocation]
 149 
 150             postsTyped = NSEvent.nsToJavaKeyInfo(in, out);
 151             if (!postsTyped) {
 152                 testChar = KeyEvent.CHAR_UNDEFINED;
 153             }
 154 
 155             jkeyCode = out[0];
 156             jkeyLocation = out[1];
 157             jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) :
 158                                            NSEvent.nsToJavaEventType(eventType);
 159         }
 160 
 161         char javaChar = NSEvent.nsToJavaChar(testChar, modifierFlags);
 162         // Some keys may generate a KEY_TYPED, but we can't determine
 163         // what that character is. That's likely a bug, but for now we
 164         // just check for CHAR_UNDEFINED.
 165         if (javaChar == KeyEvent.CHAR_UNDEFINED) {
 166             postsTyped = false;
 167         }
 168 
 169 
 170         int jmodifiers = NSEvent.nsToJavaKeyModifiers(modifierFlags);
 171         long when = System.currentTimeMillis();
 172 
 173         peer.dispatchKeyEvent(jeventType, when, jmodifiers,
 174                               jkeyCode, javaChar, jkeyLocation);
 175 
 176         // That's the reaction on the PRESSED (not RELEASED) event as it comes to
 177         // appear in MacOSX.
 178         // Modifier keys (shift, etc) don't want to send TYPED events.
 179         // On the other hand we don't want to generate keyTyped events
 180         // for clipboard related shortcuts like Meta + [CVX]
 181         boolean isMetaDown = (jmodifiers & KeyEvent.META_DOWN_MASK) != 0;
 182         if (jeventType == KeyEvent.KEY_PRESSED && postsTyped && !isMetaDown) {
 183             peer.dispatchKeyEvent(KeyEvent.KEY_TYPED, when, jmodifiers,
 184                                   KeyEvent.VK_UNDEFINED, javaChar,
 185                                   KeyEvent.KEY_LOCATION_UNKNOWN);
 186         }
 187     }
 188 }