use of org.eclipse.swt.accessibility.AccessibleTextAdapter in project tdi-studio-se by Talend.
the class ColorCombo method initAccessible.
void initAccessible() {
AccessibleAdapter accessibleAdapter = new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
String name = null;
Label label = getAssociatedLabel();
if (label != null) {
name = stripMnemonic(label.getText());
}
e.result = name;
}
@Override
public void getKeyboardShortcut(AccessibleEvent e) {
String shortcut = null;
Label label = getAssociatedLabel();
if (label != null) {
String text = label.getText();
if (text != null) {
char mnemonic = _findMnemonic(text);
if (mnemonic != '\0') {
//$NON-NLS-1$
shortcut = "Alt+" + mnemonic;
}
}
}
e.result = shortcut;
}
@Override
public void getHelp(AccessibleEvent e) {
e.result = getToolTipText();
}
};
getAccessible().addAccessibleListener(accessibleAdapter);
text.getAccessible().addAccessibleListener(accessibleAdapter);
list.getAccessible().addAccessibleListener(accessibleAdapter);
arrow.getAccessible().addAccessibleListener(new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
//$NON-NLS-1$ //$NON-NLS-2$
e.result = isDropped() ? SWT.getMessage("SWT_Close") : SWT.getMessage("SWT_Open");
}
@Override
public void getKeyboardShortcut(AccessibleEvent e) {
//$NON-NLS-1$
e.result = "Alt+Down Arrow";
}
@Override
public void getHelp(AccessibleEvent e) {
e.result = getToolTipText();
}
});
getAccessible().addAccessibleTextListener(new AccessibleTextAdapter() {
@Override
public void getCaretOffset(AccessibleTextEvent e) {
e.offset = text.getCaretPosition();
}
@Override
public void getSelectionRange(AccessibleTextEvent e) {
Point sel = text.getSelection();
e.offset = sel.x;
e.length = sel.y - sel.x;
}
});
getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {
@Override
public void getChildAtPoint(AccessibleControlEvent e) {
Point testPoint = toControl(e.x, e.y);
if (getBounds().contains(testPoint)) {
e.childID = ACC.CHILDID_SELF;
}
}
@Override
public void getLocation(AccessibleControlEvent e) {
Rectangle location = getBounds();
Point pt = getParent().toDisplay(location.x, location.y);
e.x = pt.x;
e.y = pt.y;
e.width = location.width;
e.height = location.height;
}
@Override
public void getChildCount(AccessibleControlEvent e) {
e.detail = 0;
}
@Override
public void getRole(AccessibleControlEvent e) {
e.detail = ACC.ROLE_COMBOBOX;
}
@Override
public void getState(AccessibleControlEvent e) {
e.detail = ACC.STATE_NORMAL;
}
@Override
public void getValue(AccessibleControlEvent e) {
e.result = getText();
}
});
text.getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {
@Override
public void getRole(AccessibleControlEvent e) {
e.detail = text.getEditable() ? ACC.ROLE_TEXT : ACC.ROLE_LABEL;
}
});
arrow.getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {
@Override
public void getDefaultAction(AccessibleControlEvent e) {
//$NON-NLS-1$ //$NON-NLS-2$
e.result = isDropped() ? SWT.getMessage("SWT_Close") : SWT.getMessage("SWT_Open");
}
});
}
use of org.eclipse.swt.accessibility.AccessibleTextAdapter in project translationstudio8 by heartsome.
the class TableCombo method initAccessible.
/**
* Add Accessbile listeners to label and table.
*/
void initAccessible() {
AccessibleAdapter accessibleAdapter = new AccessibleAdapter() {
public void getName(AccessibleEvent e) {
String name = null;
Label label = getAssociatedLabel();
if (label != null) {
name = stripMnemonic(text.getText());
}
e.result = name;
}
public void getKeyboardShortcut(AccessibleEvent e) {
String shortcut = null;
Label label = getAssociatedLabel();
if (label != null) {
String text = label.getText();
if (text != null) {
char mnemonic = _findMnemonic(text);
if (mnemonic != '\0') {
//$NON-NLS-1$
shortcut = "Alt+" + mnemonic;
}
}
}
e.result = shortcut;
}
public void getHelp(AccessibleEvent e) {
e.result = getToolTipText();
}
};
getAccessible().addAccessibleListener(accessibleAdapter);
text.getAccessible().addAccessibleListener(accessibleAdapter);
table.getAccessible().addAccessibleListener(accessibleAdapter);
arrow.getAccessible().addAccessibleListener(new AccessibleAdapter() {
public void getName(AccessibleEvent e) {
//$NON-NLS-1$ //$NON-NLS-2$
e.result = isDropped() ? SWT.getMessage("SWT_Close") : SWT.getMessage("SWT_Open");
}
public void getKeyboardShortcut(AccessibleEvent e) {
//$NON-NLS-1$
e.result = "Alt+Down Arrow";
}
public void getHelp(AccessibleEvent e) {
e.result = getToolTipText();
}
});
getAccessible().addAccessibleTextListener(new AccessibleTextAdapter() {
public void getCaretOffset(AccessibleTextEvent e) {
e.offset = text.getCaretPosition();
}
public void getSelectionRange(AccessibleTextEvent e) {
Point sel = text.getSelection();
e.offset = sel.x;
e.length = sel.y - sel.x;
}
});
getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {
public void getChildAtPoint(AccessibleControlEvent e) {
Point testPoint = toControl(e.x, e.y);
if (getBounds().contains(testPoint)) {
e.childID = ACC.CHILDID_SELF;
}
}
public void getLocation(AccessibleControlEvent e) {
Rectangle location = getBounds();
Point pt = getParent().toDisplay(location.x, location.y);
e.x = pt.x;
e.y = pt.y;
e.width = location.width;
e.height = location.height;
}
public void getChildCount(AccessibleControlEvent e) {
e.detail = 0;
}
public void getRole(AccessibleControlEvent e) {
e.detail = ACC.ROLE_COMBOBOX;
}
public void getState(AccessibleControlEvent e) {
e.detail = ACC.STATE_NORMAL;
}
public void getValue(AccessibleControlEvent e) {
e.result = text.getText();
}
});
text.getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {
public void getRole(AccessibleControlEvent e) {
e.detail = text.getEditable() ? ACC.ROLE_TEXT : ACC.ROLE_LABEL;
}
});
arrow.getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {
public void getDefaultAction(AccessibleControlEvent e) {
//$NON-NLS-1$ //$NON-NLS-2$
e.result = isDropped() ? SWT.getMessage("SWT_Close") : SWT.getMessage("SWT_Open");
}
});
}
Aggregations