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 *******************************************************************************/
14 package org.eclipse.swt.events;
17 import java.util.function.*;
19 import org.eclipse.swt.internal.*;
22 * Classes which implement this interface provide methods
23 * that deal with the events that are generated as the mouse
24 * pointer passes (or hovers) over controls.
26 * After creating an instance of a class that implements
27 * this interface it can be added to a control using the
28 * <code>addMouseTrackListener</code> method and removed using
29 * the <code>removeMouseTrackListener</code> method. When the
30 * mouse pointer passes into or out of the area of the screen
31 * covered by a control or pauses while over a control, the
32 * appropriate method will be invoked.
35 * @see MouseTrackAdapter
38 public interface MouseTrackListener extends SWTEventListener {
41 * Sent when the mouse pointer passes into the area of
42 * the screen covered by a control.
44 * @param e an event containing information about the mouse enter
46 void mouseEnter(MouseEvent e);
49 * Sent when the mouse pointer passes out of the area of
50 * the screen covered by a control.
52 * @param e an event containing information about the mouse exit
54 void mouseExit(MouseEvent e);
57 * Sent when the mouse pointer hovers (that is, stops moving
58 * for an (operating system specified) period of time) over
61 * @param e an event containing information about the hover
63 void mouseHover(MouseEvent e);
66 * Static helper method to create a <code>MouseTrackListener</code> for the
67 * {@link #mouseEnter(MouseEvent e)}) method, given a lambda expression or a method reference.
69 * @param c the consumer of the event
70 * @return MouseTrackListener
73 static MouseTrackListener mouseEnterAdapter(Consumer<MouseEvent> c) {
74 return new MouseTrackAdapter() {
76 public void mouseEnter(MouseEvent e) {
83 * Static helper method to create a <code>MouseTrackListener</code> for the
84 * {@link #mouseExit(MouseEvent e)}) method, given a lambda expression or a method reference.
86 * @param c the consumer of the event
87 * @return MouseTrackListener
90 static MouseTrackListener mouseExitAdapter(Consumer<MouseEvent> c) {
91 return new MouseTrackAdapter() {
93 public void mouseExit(MouseEvent e) {
100 * Static helper method to create a <code>MouseTrackListener</code> for the
101 * {@link #mouseHover(MouseEvent e)}) method, given a lambda expression or a method reference.
103 * @param c the consumer of the event
104 * @return MouseTrackListener
107 static MouseTrackListener mouseHoverAdapter(Consumer<MouseEvent> c) {
108 return new MouseTrackAdapter() {
110 public void mouseHover(MouseEvent e) {