Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Query on creating Controls using the SWT Accessibility API


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.

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

public class LabelExample {
        static Display display;
        static Shell shell;
       
        public static void 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() {
                        public void 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) {

                             
                              super.getName(arg0);

                              if(arg0.childID==1){

                      //Control lab=access.getControl();

                      //lab.setData(GcpsClientCustomerWizardMessages.getString(

                                              //"CustomerPanel.OL/COA_rollup_indicator"));

                                             label_15.setText(

                                      GcpsClientCustomerWizardMessages.getString("CustomerPanel.OL_BSP"));

              }

                     
                      }

              });


Similarly,i tried creating the checkbox also.,


Are there any alternate ways of doing this to make it work correctly  .


I appreciate if u could please look into this and do any help in this regard.



Thanks & Regards.,

Meenakshi E


IBM India Pvt. Ltd.,

Prestige Towers,Level 2,

#99,Residency Road,

Bangalore-560001.

INDIA


Ph.No.: +91-80-4007-2137

E-Mail :   melangov@xxxxxxxxxx


_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev


Back to the top