1 /*******************************************************************************
2 * Copyright (c) 2000, 2017 IBM Corporation and others.
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
9 * SPDX-License-Identifier: EPL-2.0
12 * IBM Corporation - initial API and implementation
13 *******************************************************************************/
14 package org.eclipse.swt.accessibility;
17 import java.util.function.*;
19 import org.eclipse.swt.internal.*;
22 * Classes that implement this interface provide methods
23 * that deal with the events that are generated when an
24 * accessibility client sends a message to a control.
26 * After creating an instance of a class that implements
27 * this interface it can be added to a control using the
28 * <code>addAccessibleListener</code> method and removed
29 * using the <code>removeAccessibleListener</code> method.
30 * When a client requests information, the appropriate method
33 * Note: Accessibility clients use child identifiers to specify
34 * whether they want information about a control or one of its children.
35 * Child identifiers are increasing integers beginning with 0.
36 * The identifier CHILDID_SELF represents the control itself.
39 * @see AccessibleAdapter
40 * @see AccessibleEvent
44 public interface AccessibleListener extends SWTEventListener {
47 * Sent when an accessibility client requests the name
48 * of the control, or the name of a child of the control.
50 * Return the name of the control or specified child in the
51 * <code>result</code> field of the event object. Returning
52 * an empty string tells the client that the control or child
53 * does not have a name, and returning null tells the client
54 * to use the platform name.
57 * @param e an event object containing the following fields:<ul>
58 * <li>childID [IN] - an identifier specifying the control or one of its children</li>
59 * <li>result [OUT] - the requested name string, or null</li>
62 public void getName(AccessibleEvent e);
65 * Sent when an accessibility client requests the help string
66 * of the control, or the help string of a child of the control.
68 * The information in this property should be similar to the help
69 * provided by toolTipText. It describes what the control or child
70 * does or how to use it, as opposed to getDescription, which
71 * describes appearance.
73 * Return the help string of the control or specified child in
74 * the <code>result</code> field of the event object. Returning
75 * an empty string tells the client that the control or child
76 * does not have a help string, and returning null tells the
77 * client to use the platform help string.
80 * @param e an event object containing the following fields:<ul>
81 * <li>childID [IN] - an identifier specifying the control or one of its children</li>
82 * <li>result [OUT] - the requested help string, or null</li>
85 public void getHelp(AccessibleEvent e);
88 * Sent when an accessibility client requests the keyboard shortcut
89 * of the control, or the keyboard shortcut of a child of the control.
91 * A keyboard shortcut can either be a mnemonic, or an accelerator.
92 * As a general rule, if the control or child can receive keyboard focus,
93 * then you should expose its mnemonic, and if it cannot receive keyboard
94 * focus, then you should expose its accelerator.
96 * Return the keyboard shortcut string of the control or specified child
97 * in the <code>result</code> field of the event object. Returning an
98 * empty string tells the client that the control or child does not
99 * have a keyboard shortcut string, and returning null tells the client
100 * to use the platform keyboard shortcut string.
103 * @param e an event object containing the following fields:<ul>
104 * <li>childID [IN] - an identifier specifying the control or one of its children</li>
105 * <li>result [OUT] - the requested keyboard shortcut string (example: "ALT+N"), or null</li>
108 public void getKeyboardShortcut(AccessibleEvent e);
111 * Sent when an accessibility client requests a description
112 * of the control, or a description of a child of the control.
114 * This is a textual description of the control or child's visual
115 * appearance, which is typically only necessary if it cannot be
116 * determined from other properties such as role.
118 * Return the description of the control or specified child in
119 * the <code>result</code> field of the event object. Returning
120 * an empty string tells the client that the control or child
121 * does not have a description, and returning null tells the
122 * client to use the platform description.
125 * @param e an event object containing the following fields:<ul>
126 * <li>childID [IN] - an identifier specifying the control or one of its children</li>
127 * <li>result [OUT] - the requested description string, or null</li>
130 public void getDescription(AccessibleEvent e);
133 * Static helper method to create a <code>AccessibleListener</code> for the
134 * {@link #getName(AccessibleEvent e)}) method with a lambda expression.
136 * @param c the consumer of the event
137 * @return AccessibleListener
140 public static AccessibleListener getNameAdapter(Consumer<AccessibleEvent> c) {
141 return new AccessibleAdapter() {
143 public void getName(AccessibleEvent e) {
150 * Static helper method to create a <code>AccessibleListener</code> for the
151 * {@link #getHelp(AccessibleEvent e)}) method with a lambda expression.
153 * @param c the consumer of the event
154 * @return AccessibleListener
157 public static AccessibleListener getHelpAdapter(Consumer<AccessibleEvent> c) {
158 return new AccessibleAdapter() {
160 public void getHelp(AccessibleEvent e) {
167 * Static helper method to create a <code>AccessibleListener</code> for the
168 * {@link #getKeyboardShortcut(AccessibleEvent e)}) method with a lambda expression.
170 * @param c the consumer of the event
171 * @return AccessibleListener
174 public static AccessibleListener getKeyboardShortcutAdapter(Consumer<AccessibleEvent> c) {
175 return new AccessibleAdapter() {
177 public void getKeyboardShortcut(AccessibleEvent e) {
184 * Static helper method to create a <code>AccessibleListener</code> for the
185 * {@link #getDescription(AccessibleEvent e)}) method with a lambda expression.
187 * @param c the consumer of the event
188 * @return AccessibleListener
191 public static AccessibleListener getDescriptionAdapter(Consumer<AccessibleEvent> c) {
192 return new AccessibleAdapter() {
194 public void getDescription(AccessibleEvent e) {