-
Notifications
You must be signed in to change notification settings - Fork 180
Description
Describe the bug
In Windows, but possibly other Operating Systems, Toolbar accessibility is a bit broken.
When adding an AccessibleAdapter and overriding the getName method, the name is indeed reported correctly to accessibility tools, but the Widget index is not. I am checking this using FlaUInspect (https://github.com/FlaUI/FlaUInspect).
When using accessibility drivers this results in the ToolItems no ToolItem other than the first being clickable.
To Reproduce
This code snippet has a bunch of widgets, but the toolbar is the important part:
https://github.com/fabioz/eclipse.platform.swt/blob/master/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/accessibility/ControlsWithAccessibleNamesExample.java
Relevant snippets:
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout(1, true));
AccessibleAdapter overrideAccessibleAdapter = new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
Control control = ((Accessible) e.getSource()).getControl();
if (e.childID == ACC.CHILDID_SELF) {
e.result = "Overriding Platform Name For " + control.getData("name") + " (was " + e.result + ")";
} else {
e.result = "Overriding Platform Name For " + control.getData("child") + ": " + e.childID + " (was " + e.result + ")";
}
}
@Override
public void getHelp(AccessibleEvent e) {
Control control = ((Accessible) e.getSource()).getControl();
if (e.childID == ACC.CHILDID_SELF) {
e.result = "Overriding Platform Help For " + control.getData("name") + " (was " + e.result + ")";
} else {
e.result = "Overriding Platform Help For " + control.getData("child") + ": " + e.childID + " (was " + e.result + ")";
}
}
};
ToolBar overrideToolBar = new ToolBar(shell, SWT.FLAT);
for (int i = 0; i < 3; i++) {
ToolItem item = new ToolItem(overrideToolBar, SWT.PUSH);
item.setText("Item" + i);
item.setToolTipText("ToolItem ToolTip" + i);
}
overrideToolBar.setData("name", "ToolBar");
overrideToolBar.setData("child", "ToolBar Item");
overrideToolBar.getAccessible().addAccessibleListener(overrideAccessibleAdapter);
}
Expected behavior
Toolbar and respective ToolItem buttons should report the correct index.
Screenshots
The screenshots do not show the same thing as the snipper, they show my particular example but the snippet has the same issue.



Environment:
- Select the platform(s) on which the behavior is seen:
-
- All OS
-
- Windows
-
- Linux
-
- macOS