Bug 145360 - ACC class needs split button role
Summary: ACC class needs split button role
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Carolyn MacLeod CLA
QA Contact:
URL:
Whiteboard:
Keywords: accessibility
Depends on:
Blocks: 143019
  Show dependency tree
 
Reported: 2006-06-05 11:19 EDT by Cherie Revells CLA
Modified: 2008-04-14 11:55 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Cherie Revells CLA 2006-06-05 11:19:42 EDT
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.
Comment 1 Felipe Heidrich CLA 2006-06-05 14:40:01 EDT
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
Comment 2 Carolyn MacLeod CLA 2008-04-08 16:09:13 EDT
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();
	}
}
Comment 3 Cherie Revells CLA 2008-04-14 11:39:08 EDT
Thanks Carolyn.  I think the ComboBox role is fine for us.
Comment 4 Carolyn MacLeod CLA 2008-04-14 11:55:46 EDT
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.