< prev index next >

modules/javafx.graphics/src/main/java/com/sun/glass/ui/mac/MacView.java

Print this page

        

@@ -147,20 +147,34 @@
     public void hostRemoteLayerId(int nativeLayerId) {
         // used when run inside plugin
         _hostRemoteLayerId(getNativeLayer(), nativeLayerId);
     }
 
+    protected String convertUnicodeToEmoji(String str) {
+        String emojiString = "";
+        String utf8String = str.replace("\\","");
+        String[] utf8Array = utf8String.split("u");
+
+        for(int i = 1; i < utf8Array.length; i++) {
+            emojiString += (char)Integer.parseInt(utf8Array[i], 16);
+        }
+
+        return emojiString;
+    }
+
     protected void notifyInputMethodMac(String str, int attrib, int length,
                                             int cursor, int selStart, int selLength) {
         byte atts[] = new byte[1];
         atts[0] = (byte) attrib;
         int attBounds[] = new int[2];
         attBounds[0] = 0;
         attBounds[1] = length;
         if(attrib == 4) {
+            // Convert unicode value to emoji symbol
+            String emoji = convertUnicodeToEmoji(str);
             // attrib == 4 means we are going to commit changes, so commitLength should be non-zero
-            notifyInputMethod(str, null, attBounds, atts, length, cursor, 0);
+            notifyInputMethod(emoji, null, attBounds, atts, length, cursor, 0);
         } else {
             // all other cases = just an update, update preview text but do not commit it
             if (selLength > 0
                     && str != null && str.length() > 0
                     && selStart >= 0

@@ -192,6 +206,5 @@
                 notifyInputMethod(str, null, attBounds, atts, 0, cursor, 0);
             }
         }
     }
 }
-
< prev index next >