changeset 6901:c9c58499ca05

RT-36636: [Accessibility] Select and Scrol text support (win+common)
author Felipe Heidrich <felipe.heidrich@oracle.com>
date Fri, 25 Apr 2014 11:44:38 -0700
parents efa8b7b3fedc
children ea134f222605
files modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TextInputControlSkin.java modules/controls/src/main/java/javafx/scene/control/Control.java modules/controls/src/main/java/javafx/scene/control/TextInputControl.java modules/graphics/src/main/java/com/sun/glass/ui/win/WinAccessible.java modules/graphics/src/main/java/com/sun/glass/ui/win/WinTextRangeProvider.java
diffstat 5 files changed, 45 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TextInputControlSkin.java	Fri Apr 25 14:12:21 2014 -0400
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/TextInputControlSkin.java	Fri Apr 25 11:44:38 2014 -0700
@@ -52,6 +52,7 @@
 import javafx.geometry.Rectangle2D;
 import javafx.scene.Node;
 import javafx.scene.Scene;
+import javafx.scene.accessibility.Action;
 import javafx.scene.control.ContextMenu;
 import javafx.scene.control.IndexRange;
 import javafx.scene.control.MenuItem;
@@ -846,4 +847,20 @@
         return getClassCssMetaData();
     }
 
+    /** @treatAsPrivate */
+    protected void accExecuteAction(Action action, Object... parameters) {
+        switch (action) {
+            case SCROLL_TO_INDEX: {
+                Integer start = (Integer)parameters[0];
+                Integer end = (Integer)parameters[1];
+                if (start != null && end != null) {
+                    scrollCharacterToVisible(end);
+                    scrollCharacterToVisible(start);
+                    scrollCharacterToVisible(end);
+                }
+                break;
+            } 
+            default: super.accExecuteAction(action, parameters);
+        }
+    }
 }
--- a/modules/controls/src/main/java/javafx/scene/control/Control.java	Fri Apr 25 14:12:21 2014 -0400
+++ b/modules/controls/src/main/java/javafx/scene/control/Control.java	Fri Apr 25 11:44:38 2014 -0700
@@ -936,7 +936,7 @@
             default:
         }
         if (skinBase != null) {
-            skinBase.accExecuteAction(action);
+            skinBase.accExecuteAction(action, parameters);
         }
         super.accExecuteAction(action, parameters);
     }
--- a/modules/controls/src/main/java/javafx/scene/control/TextInputControl.java	Fri Apr 25 14:12:21 2014 -0400
+++ b/modules/controls/src/main/java/javafx/scene/control/TextInputControl.java	Fri Apr 25 11:44:38 2014 -0700
@@ -1239,6 +1239,15 @@
                 String value = (String) parameters[0];
                 if (value != null) setText(value);
             }
+            case SELECT: {
+                Integer start = (Integer) parameters[0];
+                Integer end = (Integer) parameters[1];
+                if (start != null && end != null) {
+                    selectRange(start,  end);
+                }
+                break;
+            }
+            case SCROLL_TO_INDEX: //Skin
             default: super.accExecuteAction(action, parameters);
         }
     }
--- a/modules/graphics/src/main/java/com/sun/glass/ui/win/WinAccessible.java	Fri Apr 25 14:12:21 2014 -0400
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/win/WinAccessible.java	Fri Apr 25 11:44:38 2014 -0700
@@ -426,6 +426,12 @@
         return super.getAttribute(attribute, parameters);
     }
 
+    /* Overwritten in order to make is visible to WinTextRangeProvider */
+    @Override
+    protected void executeAction(Action action, Object... parameters) {
+        super.executeAction(action, parameters);
+    }
+
     private long getContainer(Role targetRole) {
         Node node = getContainerNode(targetRole);
         return node == null ? 0 : getAccessible(node);
@@ -1245,6 +1251,10 @@
 
     int get_SupportedTextSelection() {
         if (isDisposed()) return 0;
+        /* Before this can be done extra API for multiple selection will be required. */
+//        if (Boolean.TRUE.equals(getAttribute(MULTIPLE_SELECTION))) {
+//            return SupportedTextSelection_Multiple;
+//        }
         return SupportedTextSelection_Single;
     }
 
--- a/modules/graphics/src/main/java/com/sun/glass/ui/win/WinTextRangeProvider.java	Fri Apr 25 14:12:21 2014 -0400
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/win/WinTextRangeProvider.java	Fri Apr 25 11:44:38 2014 -0700
@@ -28,6 +28,7 @@
 import static javafx.scene.accessibility.Attribute.*;
 import java.text.BreakIterator;
 import javafx.geometry.Bounds;
+import javafx.scene.accessibility.Action;
 import javafx.scene.accessibility.Attribute;
 import javafx.scene.text.Font;
 import javafx.scene.text.FontWeight;
@@ -571,22 +572,25 @@
     }
 
     void Select() {
-        System.out.println("Select");
+        accessible.executeAction(Action.SELECT, start, end);
     }
 
     void AddToSelection() {
-        System.out.println("AddToSelection");
+        /* Only possible for multi selection text view */
+//        accessible.executeAction(Action.ADD_TO_SELECTION, start, end);
     }
 
     void RemoveFromSelection() {
-        System.out.println("RemoveFromSelection");
+        /* Only possible for multi selection text view */
+//        accessible.executeAction(Action.REMOVE_FROM_SELECTION, start, end);
     }
 
     void ScrollIntoView(boolean alignToTop) {
-        System.out.println("ScrollIntoView");
+        accessible.executeAction(Action.SCROLL_TO_INDEX, start, end);
     }
 
     long[] GetChildren() {
+        /* Not embedded object support currently */
         return new long[0];
     }