]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/events/FocusListener.java
85802482bf16e38d745c0d068f43b6bb8c0918d7
[simantics/platform.git] / bundles / org.eclipse.swt.win32.win32.x86_64 / src / org / eclipse / swt / events / FocusListener.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2016 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  *     Lars Vogel <Lars.Vogel@vogella.com> - Bug 506538
14  *******************************************************************************/
15 package org.eclipse.swt.events;
16
17
18 import java.util.function.*;
19
20 import org.eclipse.swt.internal.*;
21
22 /**
23  * Classes which implement this interface provide methods
24  * that deal with the events that are generated as controls
25  * gain and lose focus.
26  * <p>
27  * After creating an instance of a class that implements
28  * this interface it can be added to a control using the
29  * <code>addFocusListener</code> method and removed using
30  * the <code>removeFocusListener</code> method. When a
31  * control gains or loses focus, the appropriate method
32  * will be invoked.
33  * </p>
34  *
35  * @see FocusAdapter
36  * @see FocusEvent
37  */
38 public interface FocusListener extends SWTEventListener {
39
40 /**
41  * Sent when a control gets focus.
42  *
43  * @param e an event containing information about the focus change
44  */
45 void focusGained(FocusEvent e);
46
47 /**
48  * Sent when a control loses focus.
49  *
50  * @param e an event containing information about the focus change
51  */
52 void focusLost(FocusEvent e);
53
54
55 /**
56  * Static helper method to create a <code>FocusListener</code> for the
57  * {@link #focusGained(FocusEvent e)}) method with a lambda expression.
58  *
59  * @param c the consumer of the event
60  * @return FocusListener
61  * @since 3.106
62  */
63 static FocusListener focusGainedAdapter(Consumer<FocusEvent> c) {
64         return new FocusAdapter() {
65                 @Override
66                 public void focusGained(FocusEvent e) {
67                         c.accept(e);
68                 }
69         };
70 }
71
72 /**
73  * Static helper method to create a <code>FocusListener</code> for the
74  * {@link #focusLost(FocusEvent e)}) method with a lambda expression.
75  *
76  * @param c the consumer of the event
77  * @return FocusListener
78  * @since 3.106
79 */
80 static FocusListener focusLostAdapter(Consumer<FocusEvent> c) {
81         return new FocusAdapter() {
82                 @Override
83                 public void focusLost(FocusEvent e) {
84                         c.accept(e);
85                 }
86         };
87 }
88 }