1 /*******************************************************************************
2 * Copyright (c) 2000, 2016 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 * Lars Vogel <Lars.Vogel@vogella.com> - Bug 441116
14 *******************************************************************************/
15 package org.eclipse.swt.events;
18 import java.util.function.*;
20 import org.eclipse.swt.internal.*;
23 * Classes which implement this interface provide methods
24 * that deal with the events that are generated when selection
25 * occurs in a control.
27 * After creating an instance of a class that implements
28 * this interface it can be added to a control using the
29 * <code>addSelectionListener</code> method and removed using
30 * the <code>removeSelectionListener</code> method. When
31 * selection occurs in a control the appropriate method
35 * @see SelectionAdapter
38 public interface SelectionListener extends SWTEventListener {
41 * Sent when selection occurs in the control.
43 * For example, selection occurs in a List when the user selects
44 * an item or items with the keyboard or mouse. On some platforms,
45 * the event occurs when a mouse button or key is pressed. On others,
46 * it happens when the mouse or key is released. The exact key or
47 * mouse gesture that causes this event is platform specific.
50 * @param e an event containing information about the selection
52 void widgetSelected(SelectionEvent e);
55 * Sent when default selection occurs in the control.
57 * For example, on some platforms default selection occurs in a List
58 * when the user double-clicks an item or types return in a Text.
59 * On some platforms, the event occurs when a mouse button or key is
60 * pressed. On others, it happens when the mouse or key is released.
61 * The exact key or mouse gesture that causes this event is platform
65 * @param e an event containing information about the default selection
67 void widgetDefaultSelected(SelectionEvent e);
72 * Static helper method to create a <code>SelectionListener</code> for the
73 * {@link #widgetSelected(SelectionEvent e)}) method, given a lambda expression
74 * or a method reference.
76 * @param c the consumer of the event
77 * @return SelectionListener
80 static SelectionListener widgetSelectedAdapter(Consumer<SelectionEvent> c) {
81 return new SelectionAdapter() {
83 public void widgetSelected(SelectionEvent e) {
90 * Static helper method to create a <code>SelectionListener</code> for the
91 * {@link #widgetDefaultSelected(SelectionEvent e)}) method, given a lambda expression
92 * or a method reference.
94 * @param c the consumer of the event
95 * @return SelectionListener
98 static SelectionListener widgetDefaultSelectedAdapter(Consumer<SelectionEvent> c) {
99 return new SelectionAdapter() {
101 public void widgetDefaultSelected(SelectionEvent e) {