changeset 4879:7e97533153b8

7156194: [macosx] Can't type non-ASCII characters into applets Reviewed-by: anthony
author dcherepanov
date Tue, 03 Apr 2012 14:05:38 +0400
parents 859be9ab035e
children 13b099d9694f
files src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java src/macosx/classes/sun/lwawt/macosx/CPlatformView.java
diffstat 3 files changed, 30 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java	Mon Apr 02 19:22:04 2012 +0400
+++ b/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java	Tue Apr 03 14:05:38 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/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java	Mon Apr 02 19:22:04 2012 +0400
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java	Tue Apr 03 14:05:38 2012 +0400
@@ -123,7 +123,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);
@@ -179,6 +179,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.
@@ -191,4 +195,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/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java	Mon Apr 02 19:22:04 2012 +0400
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java	Tue Apr 03 14:05:38 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() {