Bug 40966 - Toggle buttons read as checkboxes using MSAA
Summary: Toggle buttons read as checkboxes using MSAA
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P1 normal (vote)
Target Milestone: ---   Edit
Assignee: Tod Creasey CLA
QA Contact:
URL:
Whiteboard:
Keywords: accessibility
Depends on:
Blocks:
 
Reported: 2003-07-30 14:46 EDT by Tod Creasey CLA
Modified: 2004-04-06 15:46 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tod Creasey CLA 2003-07-30 14:46:53 EDT
20030730

When you give focus to a toolbar button that is a toggle button it is read as 
a checkbox by MSAA rather than as a toggle button.

STEPS
1) Select a toggle button on a tool bar
2) Look at it using Inspect Objects - its type will be checkbox
Comment 1 Carolyn MacLeod CLA 2004-03-29 14:18:39 EST
Ignore previous priority reassignment to P4. Meant to reassign to P1, but used 
wheel mouse to scroll down.... which changed the priority to P4 when I wasn't 
looking...
Comment 2 Carolyn MacLeod CLA 2004-04-06 14:19:44 EDT
This is because there is no such thing as a "toggle" button in a toolbar on 
Windows... it is actually a "check" button. Here's the relevant paragraph from 
the MSDN.

BTNS_CHECK 
Version 5.80. Creates a dual-state push button that toggles between the 
pressed and nonpressed states each time the user clicks it. The button has a 
different background color when it is in the pressed state.

Having said that, however, we can fake it so that the MS inspector reads "push 
button" for the role, and "pressed" (or nothing) for the state.

Now think about this... is that what you really want? What is wrong with JAWS 
saying "checkbox, checked" or "checkbox, not checked" for a 'toggle-ish' 
button in a toolbar? I sounds ok to me, and makes more sense - i.e. conveys 
more information - than having JAWS read "push button, pressed" when it's 
pressed, and just "push button" when it isn't. Please make sure you really 
want to change the current behavior before you do anything further...

Moving this bug back to UI to make this decision, and if you decide to do it 
(against my recommendation <g>) then you need to implement it as outlined in 
the SWT snippet example below.

So... here's an SWT snippet to play with, to help you make your decision.
Compare this, using MSAA Inspector and using JAWS, to the equivalent buttons 
in MS Word. To make the snippet behave like Word, uncomment the commented 
lines. Word does not give focus to tool buttons, so they are less accessible 
than we are there... but also, I don't think that saying "push button" is very 
accessible for an unselected toggle.

import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.accessibility.*;

public class ToggleButtonInToolBarTest {
	static Display display;
	static Shell shell;
	static String[] toolNames = {"B", "I", "U"};
	static String[] toolTips = {"Bold", "Italic", "Underline"};
		
	public static void main(String[] args) {
		display = new Display();
		shell = new Shell(display);
		shell.setLayout(new GridLayout());
		shell.setText("Toggles In ToolBar");
		
		ToolBar toolBar = new ToolBar(shell, SWT.FLAT);
		for (int tool = 0; tool < toolNames.length; tool++) {
       		ToolItem item = new ToolItem(toolBar, SWT.CHECK);
	        item.setText(toolNames[tool]);
			item.setToolTipText(toolTips[tool]);
		}
		toolBar.getAccessible().addAccessibleListener(new 
AccessibleAdapter() {
			public void getName(AccessibleEvent e) {
				if (e.childID != ACC.CHILDID_SELF) {
					Accessible accessible = (Accessible) 
e.getSource();
					ToolBar toolBar = (ToolBar) 
accessible.getControl();
					ToolItem item = toolBar.getItem
(e.childID);
					if (item != null) {
						e.result = item.getToolTipText
();
					}
				}
			}
		});
//		toolBar.getAccessible().addAccessibleControlListener(new 
AccessibleControlAdapter() {
//			public void getRole(AccessibleControlEvent e) {
//				if (e.childID != ACC.CHILDID_SELF) {
//					Accessible accessible = (Accessible) 
e.getSource();
//					ToolBar toolBar = (ToolBar) 
accessible.getControl();
//					ToolItem item = toolBar.getItem
(e.childID);
//					if (item != null) {
//						e.detail = ACC.ROLE_PUSHBUTTON;
//					}
//				}
//			}
//			public void getState(AccessibleControlEvent e) {
//				if (e.childID != ACC.CHILDID_SELF) {
//					Accessible accessible = (Accessible) 
e.getSource();
//					ToolBar toolBar = (ToolBar) 
accessible.getControl();
//					ToolItem item = toolBar.getItem
(e.childID);
//					if (item != null) {
//						e.detail = ACC.STATE_FOCUSABLE;
//						if (item.getSelection()) {
//							e.detail |= 
ACC.STATE_PRESSED;
//						}
//					}
//				}
//			}
//		});
		
		shell.pack();
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) display.sleep();
		}
		display.dispose();
	}

	static Image createToolBarIcon(Display display, String fileName) {
		try {
			ImageData source = new ImageData
(ToggleButtonInToolBarTest.class.getResourceAsStream(fileName + ".gif"));
			ImageData mask = source.getTransparencyMask();
			return new Image(display, source, mask);
		} catch (Exception e) {
		}
		return null;
	}
}
Comment 3 Tod Creasey CLA 2004-04-06 15:46:36 EDT
We won't want to do this for every button we create - that would be overkill.

We can leave it as is if that is the OS support.