]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/accessibility/AccessibleListener.java
Merge branch 'bug-623' into release/1.43.0
[simantics/platform.git] / bundles / org.eclipse.swt.win32.win32.x86_64 / src / org / eclipse / swt / accessibility / AccessibleListener.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2017 IBM Corporation and others.
3  *
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/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.swt.accessibility;
15
16
17 import java.util.function.*;
18
19 import org.eclipse.swt.internal.*;
20
21 /**
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.
25  * <p>
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
31  * will be invoked.
32  * </p><p>
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.
37  * </p>
38  *
39  * @see AccessibleAdapter
40  * @see AccessibleEvent
41  *
42  * @since 2.0
43  */
44 public interface AccessibleListener extends SWTEventListener {
45
46         /**
47          * Sent when an accessibility client requests the name
48          * of the control, or the name of a child of the control.
49          * <p>
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.
55          * </p>
56          *
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>
60          * </ul>
61          */
62         public void getName(AccessibleEvent e);
63
64         /**
65          * Sent when an accessibility client requests the help string
66          * of the control, or the help string of a child of the control.
67          * <p>
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.
72          * </p><p>
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.
78          * </p>
79          *
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>
83          * </ul>
84          */
85         public void getHelp(AccessibleEvent e);
86
87         /**
88          * Sent when an accessibility client requests the keyboard shortcut
89          * of the control, or the keyboard shortcut of a child of the control.
90          * <p>
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.
95          * </p><p>
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.
101          * </p>
102          *
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>
106          * </ul>
107          */
108         public void getKeyboardShortcut(AccessibleEvent e);
109
110         /**
111          * Sent when an accessibility client requests a description
112          * of the control, or a description of a child of the control.
113          * <p>
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.
117          * </p><p>
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.
123          * </p>
124          *
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>
128          * </ul>
129          */
130         public void getDescription(AccessibleEvent e);
131
132         /**
133          * Static helper method to create a <code>AccessibleListener</code> for the
134          * {@link #getName(AccessibleEvent e)}) method with a lambda expression.
135          *
136          * @param c the consumer of the event
137          * @return AccessibleListener
138          * @since 3.106
139         */
140         public static AccessibleListener getNameAdapter(Consumer<AccessibleEvent> c) {
141                 return new AccessibleAdapter() {
142                         @Override
143                         public void getName(AccessibleEvent e) {
144                                 c.accept(e);
145                         }
146                 };
147         }
148
149         /**
150          * Static helper method to create a <code>AccessibleListener</code> for the
151          * {@link #getHelp(AccessibleEvent e)}) method with a lambda expression.
152          *
153          * @param c the consumer of the event
154          * @return AccessibleListener
155          * @since 3.106
156         */
157         public static AccessibleListener getHelpAdapter(Consumer<AccessibleEvent> c) {
158                 return new AccessibleAdapter() {
159                         @Override
160                         public void getHelp(AccessibleEvent e) {
161                                 c.accept(e);
162                         }
163                 };
164         }
165
166         /**
167          * Static helper method to create a <code>AccessibleListener</code> for the
168          * {@link #getKeyboardShortcut(AccessibleEvent e)}) method with a lambda expression.
169          *
170          * @param c the consumer of the event
171          * @return AccessibleListener
172          * @since 3.106
173         */
174         public static AccessibleListener getKeyboardShortcutAdapter(Consumer<AccessibleEvent> c) {
175                 return new AccessibleAdapter() {
176                         @Override
177                         public void getKeyboardShortcut(AccessibleEvent e) {
178                                 c.accept(e);
179                         }
180                 };
181         }
182
183         /**
184          * Static helper method to create a <code>AccessibleListener</code> for the
185          * {@link #getDescription(AccessibleEvent e)}) method with a lambda expression.
186          *
187          * @param c the consumer of the event
188          * @return AccessibleListener
189          * @since 3.106
190         */
191         public static AccessibleListener getDescriptionAdapter(Consumer<AccessibleEvent> c) {
192                 return new AccessibleAdapter() {
193                         @Override
194                         public void getDescription(AccessibleEvent e) {
195                                 c.accept(e);
196                         }
197                 };
198         }
199 }