]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/events/MouseEvent.java
24a36df298a6e1993687ea1a219a7d71044c36df
[simantics/platform.git] / bundles / org.eclipse.swt.win32.win32.x86_64 / src / org / eclipse / swt / events / MouseEvent.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2012 IBM Corporation and others.
3  *
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/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.swt.events;
15
16
17 import org.eclipse.swt.widgets.*;
18
19 /**
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.
24  * <p>
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>.
28  * </p>
29  *
30  * @see MouseListener
31  * @see MouseMoveListener
32  * @see MouseTrackListener
33  * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
34  */
35
36 public class MouseEvent extends TypedEvent {
37
38         /**
39          * the button that was pressed or released;
40          * <ul>
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>
44          * <li>etc.</li>
45          * </ul>
46          */
47         public int button;
48
49         /**
50          * the state of the keyboard modifier keys and mouse masks
51          * at the time the event was generated.
52          *
53          * @see org.eclipse.swt.SWT#MODIFIER_MASK
54          * @see org.eclipse.swt.SWT#BUTTON_MASK
55          */
56         public int stateMask;
57
58         /**
59          * the widget-relative, x coordinate of the pointer
60          * at the time the mouse button was pressed or released
61          */
62         public int x;
63
64         /**
65          * the widget-relative, y coordinate of the pointer
66          * at the time the mouse button was pressed or released
67          */
68         public int y;
69
70         /**
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.
74          *
75          * @since 3.3
76          */
77         public int count;
78
79         static final long serialVersionUID = 3257288037011566898L;
80
81 /**
82  * Constructs a new instance of this class based on the
83  * information in the given untyped event.
84  *
85  * @param e the untyped event containing the information
86  */
87 public MouseEvent(Event e) {
88         super(e);
89         this.x = e.x;
90         this.y = e.y;
91         this.button = e.button;
92         this.stateMask = e.stateMask;
93         this.count = e.count;
94 }
95
96 /**
97  * Returns a string containing a concise, human-readable
98  * description of the receiver.
99  *
100  * @return a string representation of the event
101  */
102 @Override
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)
108                 + " x=" + x
109                 + " y=" + y
110                 + " count=" + count
111                 + "}";
112 }
113 }