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 hiding and showing of menus.
25 * After creating an instance of a class that implements
26 * this interface it can be added to a menu using the
27 * <code>addMenuListener</code> method and removed using
28 * the <code>removeMenuListener</code> method. When the
29 * menu is hidden or shown, the appropriate method will
36 public interface MenuListener extends SWTEventListener {
39 * Sent when a menu is hidden.
41 * @param e an event containing information about the menu operation
43 void menuHidden(MenuEvent e);
46 * Sent when a menu is shown.
48 * @param e an event containing information about the menu operation
50 void menuShown(MenuEvent e);
53 * Static helper method to create a <code>MenuListener</code> for the
54 * {@link #menuHidden(MenuEvent e)}) method, given a lambda expression or a method reference.
56 * @param c the consumer of the event
57 * @return MenuListener
60 static MenuListener menuHiddenAdapter(Consumer<MenuEvent> c) {
61 return new MenuAdapter() {
63 public void menuHidden(MenuEvent e) {
70 * Static helper method to create a <code>MenuListener</code> for the
71 * {@link #menuShown(MenuEvent e)}) method, given a lambda expression or a method reference.
73 * @param c the consumer of the event
74 * @return MenuListener
77 static MenuListener menuShownAdapter(Consumer<MenuEvent> c) {
78 return new MenuAdapter() {
80 public void menuShown(MenuEvent e) {