changeset 4889:ea8458a4ada3

7124316: [macosx] Passive and Peered IMF Client does not cope with input methods Reviewed-by: art, alexp
author kizune
date Wed, 25 Jan 2012 21:32:01 +0300
parents 4a8cbf11c3b4
children fe56f3a406ce 988c39c7b9ac
files src/macosx/classes/sun/lwawt/LWTextComponentPeer.java
diffstat 1 files changed, 22 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/classes/sun/lwawt/LWTextComponentPeer.java	Wed Jan 25 20:28:16 2012 +0400
+++ b/src/macosx/classes/sun/lwawt/LWTextComponentPeer.java	Wed Jan 25 21:32:01 2012 +0300
@@ -32,8 +32,11 @@
 import java.awt.SystemColor;
 import java.awt.TextComponent;
 import java.awt.event.TextEvent;
+import java.awt.event.InputMethodListener;
+import java.awt.event.InputMethodEvent;
 import java.awt.im.InputMethodRequests;
 import java.awt.peer.TextComponentPeer;
+import sun.awt.AWTAccessor;
 
 import javax.swing.JComponent;
 import javax.swing.event.DocumentEvent;
@@ -43,7 +46,7 @@
 
 abstract class LWTextComponentPeer<T extends TextComponent, D extends JComponent>
         extends LWComponentPeer<T, D>
-        implements DocumentListener, TextComponentPeer {
+        implements DocumentListener, TextComponentPeer, InputMethodListener {
 
     /**
      * Character with reasonable value between the minimum width and maximum.
@@ -68,6 +71,7 @@
         }
         setEditable(getTarget().isEditable());
         setText(getTarget().getText());
+        getTarget().addInputMethodListener(this);
         final int start = getTarget().getSelectionStart();
         final int end = getTarget().getSelectionEnd();
         if (end > start) {
@@ -165,7 +169,9 @@
 
     @Override
     public final InputMethodRequests getInputMethodRequests() {
-        return null;
+        synchronized (getDelegateLock()) {
+            return getTextComponent().getInputMethodRequests();
+        }
     }
 
     @Override
@@ -195,4 +201,18 @@
     public final void removeUpdate(final DocumentEvent e) {
         sendTextEvent(e);
     }
+
+    @Override
+    public void inputMethodTextChanged(InputMethodEvent event) {
+        synchronized (getDelegateLock()) {
+            AWTAccessor.getComponentAccessor().processEvent(getTextComponent(), event);
+        }
+    }
+
+    @Override
+    public void caretPositionChanged(InputMethodEvent event) {
+        synchronized (getDelegateLock()) {
+            AWTAccessor.getComponentAccessor().processEvent(getTextComponent(), event);
+        }
+    }
 }