Hi experts,
Please consider the attached example code.
When running on Windows with Narrator active (verbosity level set to 4 -
Some text details), the only text to hear is "tab contains 5 items". I
have no clue how to let it tell the current selection (initially or
after changing). Could someone please help me further? Thanks in advance.
--
Thomas
import org.eclipse.swt.*;
import org.eclipse.swt.accessibility.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
/**
* @author Thomas Singer
*/
public class AccessibilityTest {
public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
new MyControl(shell);
shell.setSize(400, 300);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
private static class MyControl extends Composite {
private static final int COUNT = 5;
private int value;
public MyControl(Composite parent) {
super(parent, 0);
addListener(SWT.Paint, event -> {
final Point size = getSize();
event.gc.drawString(String.valueOf(value),
size.x / 2, size.y / 2);
});
addListener(SWT.Traverse, event -> {
if (event.detail ==
SWT.TRAVERSE_ARROW_PREVIOUS) {
value = (value + COUNT - 1) % COUNT;
}
else if (event.detail ==
SWT.TRAVERSE_ARROW_NEXT) {
value = (value + 1) % COUNT;
}
else {
return;
}
getAccessible().selectionChanged();
redraw();
});
getAccessible().addAccessibleControlListener(new
AccessibleControlAdapter() {
@Override
public void getRole(AccessibleControlEvent e) {
if (e.childID == ACC.CHILDID_SELF) {
e.detail = ACC. ROLE_TABFOLDER;
}
else {
e.detail = ACC. ROLE_TABITEM;
}
}
@Override
public void
getChildCount(AccessibleControlEvent e) {
e.detail = COUNT;
}
@Override
public void getChildren(AccessibleControlEvent
e) {
final Integer[] children = new
Integer[COUNT];
for (int i = 0; i < children.length;
i++) {
children[i] = i;
}
e.children = children;
}
@Override
public void getSelection(AccessibleControlEvent
e) {
getValue(e);
}
@Override
public void getValue(AccessibleControlEvent e) {
if (e.childID >= 0) {
e.result = "value " + value;
}
else {
e.result = "control";
}
}
});
}
}
}
_______________________________________________
platform-dev mailing list
platform-dev@eclipse.org
To unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/platform-dev