7156194: [macosx] Can't type non-ASCII characters into applets
authordcherepanov
Wed, 18 Apr 2012 09:29:09 +0400
changeset 12417 3a2e4787eae5
parent 12416 7f39181f3c6e
child 12418 f749f1ed92ca
7156194: [macosx] Can't type non-ASCII characters into applets Reviewed-by: anthony, art
jdk/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java
jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java
jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java	Tue Apr 17 21:40:12 2012 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java	Wed Apr 18 09:29:09 2012 +0400
@@ -89,12 +89,19 @@
     }
 
     public void handleKeyEvent(int eventType, int modifierFlags, String characters,
+                               String charsIgnoringMods, boolean isRepeat, short keyCode,
+                               boolean needsKeyTyped) {
+        responder.handleKeyEvent(eventType, modifierFlags, charsIgnoringMods, keyCode, needsKeyTyped);
+    }
+
+    // REMIND: delete this method once 'deploy' changes for 7156194 is pushed
+    public void handleKeyEvent(int eventType, int modifierFlags, String characters,
                                String charsIgnoringMods, boolean isRepeat, short keyCode) {
-        responder.handleKeyEvent(eventType, modifierFlags, charsIgnoringMods, keyCode);
+        handleKeyEvent(eventType, modifierFlags, characters, charsIgnoringMods, isRepeat, keyCode, true);
     }
 
     public void handleInputEvent(String text) {
-        new RuntimeException("Not implemented");
+        responder.handleInputEvent(text);
     }
 
     public void handleFocusEvent(boolean focused) {
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java	Tue Apr 17 21:40:12 2012 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java	Wed Apr 18 09:29:09 2012 +0400
@@ -117,7 +117,7 @@
      * Handles key events.
      */
     void handleKeyEvent(int eventType, int modifierFlags, String chars,
-                        short keyCode) {
+                        short keyCode, boolean needsKeyTyped) {
         boolean isFlagsChangedEvent =
             isNpapiCallback ? (eventType == CocoaConstants.NPCocoaEventFlagsChanged) :
                               (eventType == CocoaConstants.NSFlagsChanged);
@@ -173,6 +173,10 @@
         peer.dispatchKeyEvent(jeventType, when, jmodifiers,
                               jkeyCode, javaChar, jkeyLocation);
 
+        // Current browser may be sending input events, so don't
+        // post the KEY_TYPED here.
+        postsTyped &= needsKeyTyped;
+
         // 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.
@@ -185,4 +189,19 @@
                                   KeyEvent.KEY_LOCATION_UNKNOWN);
         }
     }
+
+    void handleInputEvent(String text) {
+        if (text != null) {
+            int index = 0, length = text.length();
+            char c;
+            while (index < length) {
+                c = text.charAt(index);
+                peer.dispatchKeyEvent(KeyEvent.KEY_TYPED,
+                                      System.currentTimeMillis(),
+                                      0, KeyEvent.VK_UNDEFINED, c,
+                                      KeyEvent.KEY_LOCATION_UNKNOWN);
+                index++;
+            }
+        }
+    }
 }
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java	Tue Apr 17 21:40:12 2012 +0400
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java	Wed Apr 18 09:29:09 2012 +0400
@@ -199,7 +199,7 @@
 
     private void deliverKeyEvent(NSEvent event) {
         responder.handleKeyEvent(event.getType(), event.getModifierFlags(),
-                                 event.getCharactersIgnoringModifiers(), event.getKeyCode());
+                                 event.getCharactersIgnoringModifiers(), event.getKeyCode(), true);
     }
 
     private void deliverWindowDidExposeEvent() {