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 * Lars Vogel <Lars.Vogel@vogella.com> - Bug 513037
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 as mouse buttons
27 * After creating an instance of a class that implements
28 * this interface it can be added to a control using the
29 * <code>addMouseListener</code> method and removed using
30 * the <code>removeMouseListener</code> method. When a
31 * mouse button is pressed or released, the appropriate method
38 public interface MouseListener extends SWTEventListener {
41 * Sent when a mouse button is pressed twice within the
42 * (operating system specified) double click period.
44 * @param e an event containing information about the mouse double click
46 * @see org.eclipse.swt.widgets.Display#getDoubleClickTime()
48 void mouseDoubleClick(MouseEvent e);
51 * Sent when a mouse button is pressed.
53 * @param e an event containing information about the mouse button press
55 void mouseDown(MouseEvent e);
58 * Sent when a mouse button is released.
60 * @param e an event containing information about the mouse button release
62 void mouseUp(MouseEvent e);
66 * Static helper method to create a <code>MouseListener</code> for the
67 * {@link #mouseDoubleClick(MouseEvent e)}) method with a lambda expression.
69 * @param c the consumer of the event
70 * @return MouseListener
74 static MouseListener mouseDoubleClickAdapter(Consumer<MouseEvent> c) {
75 return new MouseAdapter() {
77 public void mouseDoubleClick(MouseEvent e) {
84 * Static helper method to create a <code>MouseListener</code> for the
85 * {@link #mouseDown(MouseEvent e)}) method with a lambda expression.
87 * @param c the consumer of the event
88 * @return MouseListener
92 static MouseListener mouseDownAdapter(Consumer<MouseEvent> c) {
93 return new MouseAdapter() {
95 public void mouseDown(MouseEvent e) {
102 * Static helper method to create a <code>MouseListener</code> for the
103 * {@link #mouseUp(MouseEvent e)}) method with a lambda expression.
105 * @param c the consumer of the event
106 * @return MouseListener
110 static MouseListener mouseUpAdapter(Consumer<MouseEvent> c) {
111 return new MouseAdapter() {
113 public void mouseUp(MouseEvent e) {