Community
Participate
Working Groups
I am working on accessibility in the GEF palette. There is a button in the GEF palette that has an arrow with a dropdown list similar to some of the toolbar buttons in Eclipse. I need to configure the accessibility role for the button in the GEF palette. I noticed that a screen reader will say "split button" for the toolbar buttons in Eclipse so I guess I want to use this same role. However, I can't seem to find how I would do this. I think a "split button" role needs to be defined in org.eclipse.swt.accessibility.ACC.
From MSDN: ROLE_SYSTEM_SPLITBUTTON The role represents a button on a toolbar that has a drop-down list icon directly adjacent to the button. (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msaa/msaaccrf_4nub.asp) Not sure what to use in GTK: http://developer.gnome.org/doc/API/2.0/atk/AtkObject.html#AtkRole
There is no equivalent on any other platform. (For info, the Mac kAXPopupButtonRole and GTK's ATK_ROLE_POPUP_MENU seem close, but they just represent the menu itself). Mozilla has apparently defined a split-button role (currently in beta) for its browser, which they map to ATK_ROLE_PUSH_BUTTON on GTK, NSAccessibilityButtonRole on Mac Cocoa, and ROLE_SYSTEM_SPLITBUTTON on Windows. I guess we could do something like that, but not for 3.4 because we are past API freeze. For now, here are 2 suggestions to think about: 1) Does ComboBox role work for you, i.e. does pushing on either the button or the arrow pop up the menu? If so, maybe just use ACC.ROLE_COMBOBOX. 2) Have you tried creating a real splitbutton and using that for your GEF palette button? This can be achieved by creating a toolbar with a dropdown button child. Here's a snippet: import org.eclipse.swt.*; import org.eclipse.swt.accessibility.*; import org.eclipse.swt.events.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.widgets.*; import org.eclipse.swt.layout.*; public class SplitButtonTest { static Display display; static Shell shell; static Menu menu = null; static boolean visible = false; public static void main(String[] args) { display = new Display(); shell = new Shell(display); shell.setLayout(new GridLayout()); ToolBar toolBar = new ToolBar(shell, SWT.FLAT); ToolItem dropdown = new ToolItem (toolBar, SWT.DROP_DOWN); dropdown.setImage(display.getSystemImage(SWT.ICON_QUESTION)); dropdown.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (menu == null) { menu = new Menu(shell); for (int i = 0; i < 5; ++i) { String text = "Drop_Down Item " + i; MenuItem menuItem = new MenuItem(menu, SWT.NONE); menuItem.setText(text); menuItem.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { System.out.println("drop down menu item selected: " + e.getSource()); menu.setVisible(false); visible = false; } }); } } if (e.detail == SWT.ARROW) { System.out.println("drop down arrow selected"); if (visible) { menu.setVisible(false); visible = false; } else { ToolItem toolItem = (ToolItem) e.widget; ToolBar toolBar = toolItem.getParent(); Rectangle toolItemBounds = toolItem.getBounds(); Point point = toolBar.toDisplay(new Point(toolItemBounds.x, toolItemBounds.y)); menu.setLocation(point.x, point.y + toolItemBounds.height); menu.setVisible(true); visible = true; } } else { System.out.println("drop down tool selected"); } } }); toolBar.getAccessible().addAccessibleListener(new AccessibleAdapter() { public void getName(AccessibleEvent e) { e.result = "This is a Question Mark"; } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }
Thanks Carolyn. I think the ComboBox role is fine for us.
Thanks, Cherie. I will close this bug as "Won't fix", then. If someone really needs to create a custom split button, knowing that it will only be seen as a push button on other platforms, then they can reopen.