Here's a simple example that uses the
SWT accessibility API to change the text spoken for a label to something
other than the default.
It uses setData to save an alternate
string for the Label, but you could get the string from anywhere you like.
Try modifying this snippet to test your
checkbox/combo problem.
It actually should work correctly *without*
using SWT accessibility, so if you get a simple checkbox/combo snippet
that shows the problem, please open a bug report against eclipse platform
swt in the eclipse bugzilla and paste in your snippet.
publicstaticvoid
main(String[] args) {
display
= new
Display();
shell
= new
Shell(display);
shell.setLayout(new
GridLayout());
Label label = new
Label(shell,
SWT.NONE);
label.setText("This
is the label's text.");
label.setData("This
is the string that you want the screen reader to speak instead of the label's
text.");
label.getAccessible().addAccessibleListener(new
AccessibleAdapter() {
publicvoid
getName(AccessibleEvent event) {
Accessible accessible = (Accessible) event.getSource();
Control control = accessible.getControl();
event.result
= (String) control.getData();
}
});
shell.pack();
shell.open();
while
(!shell.isDisposed())
{
if
(!display.readAndDispatch())
display.sleep();
}
}
}
Carolyn
Meenakshi Elangovan <melangov@xxxxxxxxxx> Sent by: platform-swt-dev-bounces@xxxxxxxxxxx
08/01/2006 08:05 AM
Please respond to
"Eclipse Platform SWT component developers list." <platform-swt-dev@xxxxxxxxxxx>
To
platform-swt-dev@xxxxxxxxxxx
cc
Subject
[platform-swt-dev] Query on creating
Controls using the SWT Accessibility
API
Hi.,
I am trying to develop controls which is compatible and readable by IBM
HomePageReader(Desktop Reader),
Firstly i used SWT Accessibility API (org.eclipse.swt.*) to create controls
such as Checkbox and Labels.
For eg : Consider wizard having 2 controls
Label
Control Type
=====
===========
COA
unchecked Checkbox
OfferLetter combobox
The desktop reader reads the message as follows ( COA ---
unchecked checkbox ---- COA ----Offerletter )
COA is read twice instead of once at the start.
It is reading the label ,checkbox and again the name of the first label
and then the other label...
Here,the first label is read twice...
So,as to fix this issue,I tried creating the label in the following way...
final Label label_15 = new Label(container, SWT.NONE);
access=label_15.getAccessible();
final FormData formData_34 = new FormData();
formData_34.bottom =
new FormAttachment(0, 395);
formData_34.right = new
FormAttachment(label_13, 135, SWT.LEFT);
formData_34.top = new
FormAttachment(0, 375);
formData_34.left = new
FormAttachment(label_13, 0, SWT.LEFT);
label_15.setLayoutData(formData_34);
access.addAccessibleListener(new
AccessibleAdapter(){
public void getName(AccessibleEvent arg0) {