Exemplo n.º 1
0
  void initAccessible() {
    Accessible accessible = getAccessible();
    accessible.addAccessibleListener(
        new AccessibleAdapter() {
          @Override
          public void getName(AccessibleEvent e) {
            e.result = parse(text);
          }
        });

    accessible.addAccessibleControlListener(
        new AccessibleControlAdapter() {
          @Override
          public void getChildAtPoint(AccessibleControlEvent e) {
            e.childID = ACC.CHILDID_SELF;
          }

          @Override
          public void getLocation(AccessibleControlEvent e) {
            Rectangle rect = display.map(getParent(), null, getBounds());
            e.x = rect.x;
            e.y = rect.y;
            e.width = rect.width;
            e.height = rect.height;
          }

          @Override
          public void getChildCount(AccessibleControlEvent e) {
            e.detail = 0;
          }

          @Override
          public void getRole(AccessibleControlEvent e) {
            e.detail = ACC.ROLE_LINK;
          }

          @Override
          public void getState(AccessibleControlEvent e) {
            e.detail = ACC.STATE_FOCUSABLE;
            if (hasFocus()) e.detail |= ACC.STATE_FOCUSED;
          }

          @Override
          public void getDefaultAction(AccessibleControlEvent e) {
            e.result = SWT.getMessage("SWT_Press"); // $NON-NLS-1$
          }

          @Override
          public void getSelection(AccessibleControlEvent e) {
            if (hasFocus()) e.childID = ACC.CHILDID_SELF;
          }

          @Override
          public void getFocus(AccessibleControlEvent e) {
            if (hasFocus()) e.childID = ACC.CHILDID_SELF;
          }
        });
  }
Exemplo n.º 2
0
  private void initAccessible() {
    Accessible accessible = getAccessible();
    accessible.addAccessibleListener(
        new AccessibleAdapter() {
          public void getName(AccessibleEvent e) {
            e.result = getText();
          }

          public void getHelp(AccessibleEvent e) {
            e.result = getToolTipText();
          }

          public void getKeyboardShortcut(AccessibleEvent e) {
            char mnemonic = _findMnemonic(CLabel.this.text);
            if (mnemonic != '\0') {
              e.result = "Alt+" + mnemonic; // $NON-NLS-1$
            }
          }
        });

    accessible.addAccessibleControlListener(
        new AccessibleControlAdapter() {
          public void getChildAtPoint(AccessibleControlEvent e) {
            e.childID = ACC.CHILDID_SELF;
          }

          public void getLocation(AccessibleControlEvent e) {
            Rectangle rect = getDisplay().map(getParent(), null, getBounds());
            e.x = rect.x;
            e.y = rect.y;
            e.width = rect.width;
            e.height = rect.height;
          }

          public void getChildCount(AccessibleControlEvent e) {
            e.detail = 0;
          }

          public void getRole(AccessibleControlEvent e) {
            e.detail = ACC.ROLE_LABEL;
          }

          public void getState(AccessibleControlEvent e) {
            e.detail = ACC.STATE_READONLY;
          }
        });
  }