Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: fe92e3ad1ce605e8360ffe13f0fd625e324c5937 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.swt.accessibility;


import java.util.function.*;

import org.eclipse.swt.internal.*;

/**
 * Classes that implement this interface provide methods
 * that deal with the events that are generated when an
 * accessibility client sends a message to a control.
 * <p>
 * After creating an instance of a class that implements
 * this interface it can be added to a control using the
 * <code>addAccessibleListener</code> method and removed
 * using the <code>removeAccessibleListener</code> method.
 * When a client requests information, the appropriate method
 * will be invoked.
 * </p><p>
 * Note: Accessibility clients use child identifiers to specify
 * whether they want information about a control or one of its children.
 * Child identifiers are increasing integers beginning with 0.
 * The identifier CHILDID_SELF represents the control itself.
 * </p>
 *
 * @see AccessibleAdapter
 * @see AccessibleEvent
 *
 * @since 2.0
 */
public interface AccessibleListener extends SWTEventListener {

	/**
	 * Sent when an accessibility client requests the name
	 * of the control, or the name of a child of the control.
	 * <p>
	 * Return the name of the control or specified child in the
	 * <code>result</code> field of the event object. Returning
	 * an empty string tells the client that the control or child
	 * does not have a name, and returning null tells the client
	 * to use the platform name.
	 * </p>
	 *
	 * @param e an event object containing the following fields:<ul>
	 *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
	 *    <li>result [OUT] - the requested name string, or null</li>
	 * </ul>
	 */
	public void getName(AccessibleEvent e);

	/**
	 * Sent when an accessibility client requests the help string
	 * of the control, or the help string of a child of the control.
	 * <p>
	 * The information in this property should be similar to the help
	 * provided by toolTipText. It describes what the control or child
	 * does or how to use it, as opposed to getDescription, which
	 * describes appearance.
	 * </p><p>
	 * Return the help string of the control or specified child in
	 * the <code>result</code> field of the event object. Returning
	 * an empty string tells the client that the control or child
	 * does not have a help string, and returning null tells the
	 * client to use the platform help string.
	 * </p>
	 *
	 * @param e an event object containing the following fields:<ul>
	 *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
	 *    <li>result [OUT] - the requested help string, or null</li>
	 * </ul>
	 */
	public void getHelp(AccessibleEvent e);

	/**
	 * Sent when an accessibility client requests the keyboard shortcut
	 * of the control, or the keyboard shortcut of a child of the control.
	 * <p>
	 * A keyboard shortcut can either be a mnemonic, or an accelerator.
	 * As a general rule, if the control or child can receive keyboard focus,
	 * then you should expose its mnemonic, and if it cannot receive keyboard
	 * focus, then you should expose its accelerator.
	 * </p><p>
	 * Return the keyboard shortcut string of the control or specified child
	 * in the <code>result</code> field of the event object. Returning an
	 * empty string tells the client that the control or child does not
	 * have a keyboard shortcut string, and returning null tells the client
	 * to use the platform keyboard shortcut string.
	 * </p>
	 *
	 * @param e an event object containing the following fields:<ul>
	 *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
	 *    <li>result [OUT] - the requested keyboard shortcut string (example: "ALT+N"), or null</li>
	 * </ul>
	 */
	public void getKeyboardShortcut(AccessibleEvent e);

	/**
	 * Sent when an accessibility client requests a description
	 * of the control, or a description of a child of the control.
	 * <p>
	 * This is a textual description of the control or child's visual
	 * appearance, which is typically only necessary if it cannot be
	 * determined from other properties such as role.
	 * </p><p>
	 * Return the description of the control or specified child in
	 * the <code>result</code> field of the event object. Returning
	 * an empty string tells the client that the control or child
	 * does not have a description, and returning null tells the
	 * client to use the platform description.
	 * </p>
	 *
	 * @param e an event object containing the following fields:<ul>
	 *    <li>childID [IN] - an identifier specifying the control or one of its children</li>
	 *    <li>result [OUT] - the requested description string, or null</li>
	 * </ul>
	 */
	public void getDescription(AccessibleEvent e);

	/**
	 * Static helper method to create a accessible listener for the
	 * {@link #getName(AccessibleEvent e)}) method with a lambda expression.
	 *
	 * @param c the consumer of the event
	 * @return AccessibleListener
	 * @since 3.106
	*/
	public static AccessibleListener getNameAdapter(Consumer<AccessibleEvent> c) {
		return new AccessibleAdapter() {
			@Override
			public void getName(AccessibleEvent e) {
				c.accept(e);
			}
		};
	}

	/**
	 * Static helper method to create a accessible listener for the
	 * {@link #getHelp(AccessibleEvent e)}) method with a lambda expression.
	 *
	 * @param c the consumer of the event
	 * @return AccessibleListener
	 * @since 3.106
	*/
	public static AccessibleListener getHelpAdapter(Consumer<AccessibleEvent> c) {
		return new AccessibleAdapter() {
			@Override
			public void getHelp(AccessibleEvent e) {
				c.accept(e);
			}
		};
	}

	/**
	 * Static helper method to create a accessible listener for the
	 * {@link #getKeyboardShortcut(AccessibleEvent e)}) method with a lambda expression.
	 *
	 * @param c the consumer of the event
	 * @return AccessibleListener
	 * @since 3.106
	*/
	public static AccessibleListener getKeyboardShortcutAdapter(Consumer<AccessibleEvent> c) {
		return new AccessibleAdapter() {
			@Override
			public void getKeyboardShortcut(AccessibleEvent e) {
				c.accept(e);
			}
		};
	}

	/**
	 * Static helper method to create a accessible listener for the
	 * {@link #getDescription(AccessibleEvent e)}) method with a lambda expression.
	 *
	 * @param c the consumer of the event
	 * @return AccessibleListener
	 * @since 3.106
	*/
	public static AccessibleListener getDescription(Consumer<AccessibleEvent> c) {
		return new AccessibleAdapter() {
			@Override
			public void getDescription(AccessibleEvent e) {
				c.accept(e);
			}
		};
	}
}

Back to the top