Bug 320064 - StyledText and CCombo should also use preceding CLabel as accessible name
Summary: StyledText and CCombo should also use preceding CLabel as accessible name
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.7   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.6.1   Edit
Assignee: Carolyn MacLeod CLA
QA Contact:
URL:
Whiteboard:
Keywords: accessibility
Depends on:
Blocks:
 
Reported: 2010-07-16 00:47 EDT by Carolyn MacLeod CLA
Modified: 2010-08-24 11:31 EDT (History)
1 user (show)

See Also:
carolynmacleod4: review+


Attachments
patch for StyledText and CCombo to use CLabel as name (4.21 KB, patch)
2010-07-16 01:29 EDT, Carolyn MacLeod CLA
no flags Details | Diff
patch (4.37 KB, patch)
2010-08-04 17:44 EDT, Silenio Quarti CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carolyn MacLeod CLA 2010-07-16 00:47:21 EDT
Currently, StyledText and CCombo will look to see if a Label precedes them in the z-order (i.e. the Label must be a sibling, and it must be created immediately before the StyledText or CCombo), and if so, then the Label text can be used for the StyledText or CCombo's default accessible name.
Comment 1 Carolyn MacLeod CLA 2010-07-16 01:29:02 EDT
Created attachment 174467 [details]
patch for StyledText and CCombo to use CLabel as name
Comment 2 Carolyn MacLeod CLA 2010-07-16 01:38:50 EDT
SSQ, please review for 3.6.1.

Here is a snippet:
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.custom.*;

public class CLabelAccessibleNameTest {
		
	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setLayout(new GridLayout(2, false));
		
		CLabel clabel = new CLabel(shell, SWT.NONE);
		clabel.setText("CLabel for the StyledText:");
		StyledText styledText = new StyledText(shell, SWT.SINGLE | SWT.BORDER);
		styledText.setText("Some text");

		CLabel clabel2 = new CLabel(shell, SWT.NONE);
		clabel2.setText("CLabel for the CCombo:");
		CCombo ccombo = new CCombo(shell, SWT.BORDER);
		ccombo.setItems(new String[] {"one", "two", "three"});
		ccombo.setText(ccombo.getItem(0));

		shell.pack();
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) display.sleep();
		}
	}
}
Comment 3 Silenio Quarti CLA 2010-08-04 17:44:06 EDT
Created attachment 175895 [details]
patch

Car, please try this patch out. Same idea but it avoids a couple of casts and instanceof checks.

It also fixes the fact that getAssociatedLabel() would loop through all siblings when the styledtext/ccombo is the first child and still return null.
Comment 4 Carolyn MacLeod CLA 2010-08-06 09:43:01 EDT
I like that much better. I'll try it out when I get back.
Comment 5 Carolyn MacLeod CLA 2010-08-24 10:51:39 EDT
Works great - thanks. I'll release for 3.6.1 and 3.7.
Comment 6 Carolyn MacLeod CLA 2010-08-24 11:24:27 EDT
Fixed > 20100824 in HEAD for 3.7.
Comment 7 Carolyn MacLeod CLA 2010-08-24 11:31:07 EDT
Fixed > 20100824 in 3.6.1 stream.