Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8087557: [Win] [Accessibility, Dialogs] Alert Dialog content is not fully read by Screen Reader #91

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -53,6 +53,7 @@
import javafx.css.StyleableStringProperty;
import javafx.event.ActionEvent;
import javafx.geometry.Pos;
import javafx.scene.AccessibleRole;
import javafx.scene.Node;
import javafx.scene.control.ButtonBar.ButtonData;
import javafx.scene.image.Image;
Expand Down Expand Up @@ -209,6 +210,7 @@ static Label createContentLabel(String text) {
*/
public DialogPane() {
getStyleClass().add("dialog-pane");
setAccessibleRole(AccessibleRole.DIALOG);

headerTextPanel = new GridPane();
getChildren().add(headerTextPanel);
Expand Down
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2022, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package test.javafx.scene.control;

import javafx.scene.AccessibleRole;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;

/** Tests for the {@link Dialog} class. */
public class DialogTest {

private Dialog<ButtonType> dialog;

@Before
public void setUp() {
dialog = new Dialog<>();
}

@After
public void cleanUp() {
// Set a dummy result so the dialog can be closed.
dialog.setResult(new ButtonType(""));
dialog.hide();
}

@Test
public void testAccessibleRole() {
assertEquals(AccessibleRole.DIALOG, dialog.getDialogPane().getAccessibleRole());
}
}

Expand Up @@ -1299,6 +1299,7 @@ private MacVariant accessibilityAttributeValue(long attribute) {
case PAGE_ITEM: result = "page"; break;
case TAB_ITEM: result = "tab"; break;
case LIST_VIEW: result = "list"; break;
case DIALOG: result = "dialog"; break;
default:
MacRole macRole = getRole(role);
MacSubrole subRole = MacSubrole.getRole(role);
Expand Down
Expand Up @@ -101,6 +101,7 @@ final class WinAccessible extends Accessible {
private static final int UIA_ToggleToggleStatePropertyId = 30086;
private static final int UIA_AriaRolePropertyId = 30101;
private static final int UIA_ProviderDescriptionPropertyId = 30107;
private static final int UIA_IsDialogPropertyId = 30174;

/* Control Pattern Identifiers */
private static final int UIA_InvokePatternId = 10000;
Expand Down Expand Up @@ -791,6 +792,7 @@ private WinVariant GetPropertyValue(int propertyId) {
switch (role) {
case TITLED_PANE: description = "title pane"; break;
case PAGE_ITEM: description = "page"; break;
case DIALOG: description = "dialog"; break;
default:
}
}
Expand Down Expand Up @@ -830,6 +832,12 @@ private WinVariant GetPropertyValue(int propertyId) {
variant.boolVal = focus != null ? focus : false;
break;
}
case UIA_IsDialogPropertyId: {
AccessibleRole role = (AccessibleRole) getAttribute(ROLE);
variant = new WinVariant();
variant.vt = WinVariant.VT_BOOL;
variant.boolVal = (role == AccessibleRole.DIALOG);
} break;
case UIA_IsContentElementPropertyId:
case UIA_IsControlElementPropertyId: {
//TODO how to handle ControlElement versus ContentElement
Expand Down
Expand Up @@ -822,4 +822,18 @@ public enum AccessibleRole {
* </ul>
*/
TREE_VIEW,

/**
* Dialog role.
* <p>
* Attributes:
* <ul>
* <li> {@link AccessibleAttribute#TEXT} </li>
* <li> {@link AccessibleAttribute#ROLE_DESCRIPTION} </li>
* <li> {@link AccessibleAttribute#CHILDREN} </li>
* </ul>
*
* @since 17.0.6
*/
DIALOG
}
Expand Up @@ -6508,7 +6508,13 @@ Accessible getAccessible() {
}
return getRoot();//not sure
}
case ROLE: return AccessibleRole.PARENT;
case ROLE: {
if (getRoot() != null && getRoot().getAccessibleRole() == AccessibleRole.DIALOG) {
return AccessibleRole.DIALOG;
} else {
return AccessibleRole.PARENT;
}
}
case SCENE: return Scene.this;
case FOCUS_NODE: {
if (transientFocusContainer != null) {
Expand Down