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 mouse
21 * related actions occur. This includes mouse buttons
22 * being pressed and released, the mouse pointer being
23 * moved and the mouse pointer crossing widget boundaries.
25 * Note: The <code>button</code> field is an integer that
26 * represents the mouse button number. This is not the same
27 * as the <code>SWT</code> mask constants <code>BUTTONx</code>.
31 * @see MouseMoveListener
32 * @see MouseTrackListener
33 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
36 public class MouseEvent extends TypedEvent {
39 * the button that was pressed or released;
41 * <li>1 for the first button (usually 'left')</li>
42 * <li>2 for the second button (usually 'middle')</li>
43 * <li>3 for the third button (usually 'right')</li>
50 * the state of the keyboard modifier keys and mouse masks
51 * at the time the event was generated.
53 * @see org.eclipse.swt.SWT#MODIFIER_MASK
54 * @see org.eclipse.swt.SWT#BUTTON_MASK
59 * the widget-relative, x coordinate of the pointer
60 * at the time the mouse button was pressed or released
65 * the widget-relative, y coordinate of the pointer
66 * at the time the mouse button was pressed or released
71 * the number times the mouse has been clicked, as defined
72 * by the operating system; 1 for the first click, 2 for the
73 * second click and so on.
79 static final long serialVersionUID = 3257288037011566898L;
82 * Constructs a new instance of this class based on the
83 * information in the given untyped event.
85 * @param e the untyped event containing the information
87 public MouseEvent(Event e) {
91 this.button = e.button;
92 this.stateMask = e.stateMask;
97 * Returns a string containing a concise, human-readable
98 * description of the receiver.
100 * @return a string representation of the event
103 public String toString() {
104 String string = super.toString ();
105 return string.substring (0, string.length() - 1) // remove trailing '}'
106 + " button=" + button
107 + " stateMask=0x" + Integer.toHexString(stateMask)