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

Print this page

        

@@ -156,24 +156,33 @@
             jkeyLocation = out[1];
             jeventType = isNpapiCallback ? NSEvent.npToJavaEventType(eventType) :
                                            NSEvent.nsToJavaEventType(eventType);
         }
 
+        char javaChar = NSEvent.nsToJavaChar(testChar, modifierFlags);
+        // Some keys may generate a KEY_TYPED, but we can't determine
+        // what that character is. That's likely a bug, but for now we
+        // just check for CHAR_UNDEFINED.
+        if (javaChar == KeyEvent.CHAR_UNDEFINED) {
+            postsTyped = false;
+        }
+
+
         int jmodifiers = NSEvent.nsToJavaKeyModifiers(modifierFlags);
         long when = System.currentTimeMillis();
 
         peer.dispatchKeyEvent(jeventType, when, jmodifiers,
-                              jkeyCode, testChar, jkeyLocation);
+                              jkeyCode, javaChar, jkeyLocation);
 
         // That's the reaction on the PRESSED (not RELEASED) event as it comes to
         // appear in MacOSX.
         // Modifier keys (shift, etc) don't want to send TYPED events.
         // On the other hand we don't want to generate keyTyped events
         // for clipboard related shortcuts like Meta + [CVX]
         boolean isMetaDown = (jmodifiers & KeyEvent.META_DOWN_MASK) != 0;
         if (jeventType == KeyEvent.KEY_PRESSED && postsTyped && !isMetaDown) {
             peer.dispatchKeyEvent(KeyEvent.KEY_TYPED, when, jmodifiers,
-                                  KeyEvent.VK_UNDEFINED, testChar,
+                                  KeyEvent.VK_UNDEFINED, javaChar,
                                   KeyEvent.KEY_LOCATION_UNKNOWN);
         }
     }
 }