modules/controls/src/main/java/com/sun/javafx/scene/control/skin/FXVK.java

Print this page
rev 9240 : 8076423: JEP 253: Prepare JavaFX UI Controls & CSS APIs for Modularization

@@ -23,10 +23,12 @@
  * questions.
  */
 
 package com.sun.javafx.scene.control.skin;
 
+import javafx.application.ConditionalFeature;
+import javafx.application.Platform;
 import javafx.beans.property.ObjectProperty;
 import javafx.beans.property.ObjectPropertyBase;
 import javafx.beans.property.SimpleObjectProperty;
 import javafx.geometry.NodeOrientation;
 import javafx.scene.Node;

@@ -51,11 +53,11 @@
     public final void setOnAction(EventHandler<KeyEvent> value) { onAction.set(value); }
     public final EventHandler<KeyEvent> getOnAction() { return onAction.get(); }
     public final ObjectProperty<EventHandler<KeyEvent>> onActionProperty() { return onAction; }
 
 
-    final static String[] VK_TYPE_NAMES = new String[] { "text", "numeric", "url", "email" };
+    public final static String[] VK_TYPE_NAMES = new String[] { "text", "numeric", "url", "email" };
     public final static String VK_TYPE_PROP_KEY = "vkType";
 
     String[] chars;
 
     public FXVK() {

@@ -104,10 +106,34 @@
         if (vk != null) {
             vk.setAttachedNode(null);
         }
     }
 
+    private final static boolean IS_FXVK_SUPPORTED = Platform.isSupported(ConditionalFeature.VIRTUAL_KEYBOARD);
+    private static boolean USE_FXVK = IS_FXVK_SUPPORTED;
+
+    public static boolean useFXVK() {
+        return USE_FXVK;
+    }
+
+    public static void toggleUseVK(TextInputControl textInput) {
+        Integer vkType = (Integer)textInput.getProperties().get(VK_TYPE_PROP_KEY);
+        if (vkType == null) {
+            vkType = -1;
+        }
+        vkType++;
+        if (vkType < 4) {
+            USE_FXVK = true;
+            textInput.getProperties().put(VK_TYPE_PROP_KEY, vkType);
+            attach(textInput);
+        } else {
+            detach();
+            textInput.getProperties().put(VK_TYPE_PROP_KEY, null);
+            USE_FXVK = false;
+        }
+    }
+
     /***************************************************************************
      *                                                                         *
      * Methods                                                                 *
      *                                                                         *
      **************************************************************************/