Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 40965

Summary: [Workbench] Tool bar buttons require mouse focus to get read using MSAA
Product: [Eclipse Project] Platform Reporter: Tod Creasey <Tod_Creasey>
Component: UIAssignee: Tod Creasey <Tod_Creasey>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: dipalerm, Kevin_Haaland, matt, Tod_Creasey, twolff
Version: 3.0Keywords: accessibility
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
gifs for toolbar snippet none

Description Tod Creasey CLA 2003-07-30 14:44:18 EDT
20030730

When you cycle through buttons using the mouse the tooltip value will not be 
given to the MSAA interface. If you select using a mouse it will.

STEPS
1) Start up Inspect Objects
2) Tab through Eclipse until you get focus on a tool bar button. There will be 
no name or value
3) Move the button over with the mouse - you will get tool tip text
Comment 1 Carolyn MacLeod CLA 2004-04-06 12:41:12 EDT
UI needs to add a name to each of the toolbar buttons so that JAWS knows what 
name to read. Even if all you do is answer the tooltip as the MSAA name, that 
will work. Here is an SWT snippet that lets me tab through the buttons, and 
JAWS reads all of the names. Moving this bug back to UI.

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 AccessibleToolBarTest {
	static Display display;
	static Shell shell;
	static String[][] toolImageFileNames = {
			{"search"},
			{"script_wiz"},
			{"new_wiz>", null, "save", "saveas", "printer"},
			{"debug", "run"},
			{"opentype"},
		
	{"newjprj_wiz", "newpack_wiz", "newclass_wiz>", "newint_wiz", "newsbook
_wiz"},
		};
	static String[][] toolTips = {
			{"Search"},
			{"Script"},
			{"New", null, "Save", "Save As", "Print"},
			{"Debug", "Run"},
			{"Open Type"},
			{"New Java Project", "New Package", "New Class", "New 
Interface", "New Java Script"},
		};
		
	public static void main(String[] args) {
		display = new Display();
		shell = new Shell(display);
		shell.setLayout(new GridLayout());
		shell.setText("ToolBar Button Names");
		
		for (int tb = 0; tb < toolImageFileNames.length; tb++) {
			ToolBar toolBar = new ToolBar(shell, SWT.FLAT);
	        String[] toolBarFileNames = toolImageFileNames[tb];
			for (int tool = 0; tool < toolBarFileNames.length; 
tool++) {
	            String fileName = toolBarFileNames[tool];
	            if (fileName == null) {
	            	new ToolItem(toolBar, SWT.SEPARATOR);
	            } else if (fileName.endsWith(">")) {
	           		ToolItem item = new ToolItem(toolBar, 
SWT.DROP_DOWN);
	            	item.setImage(createToolBarIcon(display, 
fileName.substring(0, fileName.length() - 1)));
					item.setToolTipText(toolTips[tb]
[tool]);
	            } else {
	           		ToolItem item = new ToolItem(toolBar, 
SWT.PUSH);
	            	item.setImage(createToolBarIcon(display, fileName));
					item.setToolTipText(toolTips[tb]
[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();
						}
					}
				}
			});
	    }
		
		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
(AccessibleToolBarTest.class.getResourceAsStream(fileName + ".gif"));
			ImageData mask = source.getTransparencyMask();
			return new Image(display, source, mask);
		} catch (Exception e) {
		}
		return null;
	}
}
Comment 2 Carolyn MacLeod CLA 2004-04-06 12:45:03 EDT
Created attachment 9261 [details]
gifs for toolbar snippet

Sorry - you will need to have some gifs to try out the SWT snippet. I am
zipping them and attaching them here.
Comment 3 Tod Creasey CLA 2004-04-06 12:50:53 EDT
We should also check against 2.1.3 to be sure that this was the case then too.
Comment 4 Tod Creasey CLA 2004-05-20 10:30:15 EDT
This one is currently in the public accessibility list.
Comment 5 Carolyn MacLeod CLA 2004-05-20 13:44:19 EDT
I wrote the code for you - here it is. It is an easy fix, and anyone who adds 
a tooltip to their toolbar button will be accessible for free. Please add it 
for 3.0. Thanks! (oh, this just fixes the main toolbar and the perspective 
switching toolbar. I leave it up to you to add this same fix to the view 
toolbars - I don't know the framework well enough).

In org.eclipse.jface.action.ToolBarManager class, method createControl:

public ToolBar createControl(Composite parent) {
	if (!toolBarExist() && parent != null) {
		toolBar = new ToolBar(parent, itemStyle);
		toolBar.setMenu(getContextMenuControl());
		update(false);
		toolBar.getAccessible().addAccessibleListener(new 
AccessibleAdapter() {
			public void getName(AccessibleEvent e) {
				if (e.childID != ACC.CHILDID_SELF) {
					try {
						ToolBar bar = (ToolBar) 
((Accessible)e.getSource()).getControl();
						ToolItem item = bar.getItem
(e.childID);
						if (item != null) {
							String toolTip = 
item.getToolTipText();
							if (toolTip != null) {
								e.result = 
toolTip;
							}
						}
					} catch (ClassCastException ex) {
					} catch (IllegalArgumentException ex) {
					}
				}
			}
		});
	}
	return toolBar;
}
Comment 6 Carolyn MacLeod CLA 2004-05-20 13:46:54 EDT
*** Bug 58908 has been marked as a duplicate of this bug. ***
Comment 7 Tanya Wolff CLA 2004-06-24 12:03:36 EDT
Is this going into 3.0?
Comment 8 Michael Van Meekeren CLA 2004-06-24 13:13:10 EDT
no plans to put this in for 3.0 if it is not already in.
Comment 9 Tod Creasey CLA 2004-07-05 09:32:53 EDT
Michael are we going to do this for 3.1? If not then we should mark this  
WONTFIX
Comment 10 Tod Creasey CLA 2004-07-13 12:11:03 EDT
Patch released (with some refactoring) to builds > 20040713
Comment 11 Tod Creasey CLA 2005-05-10 14:56:17 EDT
Marking closed