changeset 6525:492c42c21d9f

RT-36267: [Accessibility] Fix LABELED_BY on Windows Reviewed-by: fheidric
author Anthony Petrov <anthony.petrov@oracle.com>
date Thu, 20 Mar 2014 13:52:40 +0400
parents c5ebcc5268b4
children 5852ce9869cd
files modules/graphics/src/main/java/com/sun/glass/ui/win/WinAccessible.java modules/graphics/src/main/java/javafx/scene/accessibility/Attribute.java
diffstat 2 files changed, 27 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/glass/ui/win/WinAccessible.java	Thu Mar 20 07:38:31 2014 +0100
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/win/WinAccessible.java	Thu Mar 20 13:52:40 2014 +0400
@@ -550,16 +550,28 @@
                 break;
             }
             case UIA_NamePropertyId: {
-               /* The name for ComboBox is provided in get_ValueString()
-                * Returning the title in the two places will cause Narrator
-                * to read the same name twice.
-                * 
-                * Note this needs means LABELED_BY no longer works for 
-                * ComboBox.
-                */
-                if (Role.COMBOBOX == getAttribute(ROLE)) break;
+                String name;
 
-                String name = (String)getAttribute(TITLE);
+                Role role = (Role)getAttribute(ROLE);
+                if (role == null) role = Role.NODE; // to prevent NPE
+                switch (role) {
+                    case COMBOBOX:
+                        // These controls use TITLE to answer get_ValueString().
+                        // Only LABELED_BY can be used to specify a name for them.
+                        name = null;
+                        break;
+                    case TEXT_FIELD:
+                    case TEXT_AREA:
+                        // Note that this results in ignoring the LabeledBy for text
+                        // controls because they return their text as the TITLE.
+                        // However, otherwise they don't work, i.e. Narrator won't read
+                        // the text. Or we should implement more advanced patterns
+                        // available on Windows 8 to support text controls properly.
+                    default:
+                        name = (String)getAttribute(TITLE);
+                        break;
+                }
+
                 if (name == null || name.length() == 0) {
                     Node label = (Node)getAttribute(LABELED_BY);
                     if (label != null) {
--- a/modules/graphics/src/main/java/javafx/scene/accessibility/Attribute.java	Thu Mar 20 07:38:31 2014 +0100
+++ b/modules/graphics/src/main/java/javafx/scene/accessibility/Attribute.java	Thu Mar 20 13:52:40 2014 +0400
@@ -296,6 +296,12 @@
 
     /**
      * Returns the title for the Node.
+     * E.g.
+     * <ul>
+     * <li>ComboBox returns a string representation of its
+     * currently selected item.
+     * <li>TextField returns the text currently entered into it.
+     * </ul>
      * Type: String
      */
     TITLE("Title", String.class),