1 /*******************************************************************************
2 * Copyright (c) 2000, 2012 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 org.eclipse.swt.widgets.*;
20 * Instances of this class are sent whenever the platform-
21 * specific trigger for showing a context menu is detected.
23 * @see MenuDetectListener
24 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
29 public final class MenuDetectEvent extends TypedEvent {
32 * The display-relative x coordinate of the pointer
33 * at the time the context menu trigger occurred.
38 * The display-relative y coordinate of the pointer
39 * at the time the context menu trigger occurred.
44 * A flag indicating whether the operation should be allowed.
45 * Setting this field to <code>false</code> will cancel the operation.
50 * The context menu trigger type.
52 * <li>{@link org.eclipse.swt.SWT#MENU_MOUSE}</li>
53 * <li>{@link org.eclipse.swt.SWT#MENU_KEYBOARD}</li>
56 * A field indicating whether the context menu was triggered by a
57 * pointing device such as a mouse (indicated by <code>MENU_MOUSE</code>),
58 * or by a focus-based device such as a keyboard (<code>MENU_KEYBOARD</code>).
59 * If the trigger was <code>MENU_KEYBOARD</code>, then the application should
60 * provide new display-relative x and y coordinates based on the current
61 * selection or the current focus.
68 private static final long serialVersionUID = -3061660596590828941L;
71 * Constructs a new instance of this class based on the
72 * information in the given untyped event.
74 * @param e the untyped event containing the information
76 public MenuDetectEvent(Event e) {
81 this.detail = e.detail;
85 * Returns a string containing a concise, human-readable
86 * description of the receiver.
88 * @return a string representation of the event
91 public String toString() {
92 String string = super.toString ();
93 return string.substring (0, string.length() - 1) // remove trailing '}'