changeset 10710:8d0e6a930b1b

8088077: [Accessibility, JAWS] DatePicker under JAWS speaks the wrong date after using arrow keys to move highlighted date across month boundaries. Reviewed-by: kcr, aghaisas
author pkbalakr
date Mon, 20 Nov 2017 15:06:49 +0530
parents 9428641bd322
children c69cde9a039e
files modules/javafx.controls/src/main/java/javafx/scene/control/DateCell.java
diffstat 1 files changed, 25 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/modules/javafx.controls/src/main/java/javafx/scene/control/DateCell.java	Fri Nov 17 05:21:37 2017 -0800
+++ b/modules/javafx.controls/src/main/java/javafx/scene/control/DateCell.java	Mon Nov 20 15:06:49 2017 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
 
 import java.time.LocalDate;
 
+import javafx.scene.AccessibleAttribute;
+import javafx.scene.AccessibleRole;
 import javafx.scene.control.skin.DateCellSkin;
 
 /**
@@ -41,6 +43,7 @@
 public class DateCell extends Cell<LocalDate> {
     public DateCell() {
         getStyleClass().add(DEFAULT_STYLE_CLASS);
+        setAccessibleRole(AccessibleRole.TEXT);
     }
 
     /** {@inheritDoc} */
@@ -60,4 +63,24 @@
      **************************************************************************/
 
     private static final String DEFAULT_STYLE_CLASS = "date-cell";
-}
+
+    /***************************************************************************
+     *                                                                         *
+     * Accessibility handling                                                  *
+     *                                                                         *
+     **************************************************************************/
+
+    /** {@inheritDoc} */
+    @Override
+    public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) {
+        switch (attribute) {
+            case TEXT: {
+                if (isFocused()) {
+                    return getText();
+                }
+                return "";
+            }
+            default: return super.queryAccessibleAttribute(attribute, parameters);
+        }
+    }
+}
\ No newline at end of file