KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > swt > events > MouseEvent


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.swt.events;
12
13
14 import org.eclipse.swt.widgets.Event;
15
16 /**
17  * Instances of this class are sent whenever mouse
18  * related actions occur. This includes mouse buttons
19  * being pressed and released, the mouse pointer being
20  * moved and the mouse pointer crossing widget boundaries.
21  * <p>
22  * Note: The <code>button</code> field is an integer that
23  * represents the mouse button number. This is not the same
24  * as the <code>SWT</code> mask constants <code>BUTTONx</code>.
25  * </p>
26  *
27  * @see MouseListener
28  * @see MouseMoveListener
29  * @see MouseTrackListener
30  */

31
32 public class MouseEvent extends TypedEvent {
33     
34     /**
35      * the button that was pressed or released; 1 for the
36      * first button, 2 for the second button, and 3 for the
37      * third button, etc.
38      */

39     public int button;
40     
41     /**
42      * the state of the keyboard modifier keys at the time
43      * the event was generated
44      */

45     public int stateMask;
46     
47     /**
48      * the widget-relative, x coordinate of the pointer
49      * at the time the mouse button was pressed or released
50      */

51     public int x;
52     
53     /**
54      * the widget-relative, y coordinate of the pointer
55      * at the time the mouse button was pressed or released
56      */

57     public int y;
58     
59     /**
60      * the number times the mouse has been clicked, as defined
61      * by the operating system; 1 for the first click, 2 for the
62      * second click and so on.
63      *
64      * @since 3.3
65      */

66     public int count;
67
68     static final long serialVersionUID = 3257288037011566898L;
69     
70 /**
71  * Constructs a new instance of this class based on the
72  * information in the given untyped event.
73  *
74  * @param e the untyped event containing the information
75  */

76 public MouseEvent(Event e) {
77     super(e);
78     this.x = e.x;
79     this.y = e.y;
80     this.button = e.button;
81     this.stateMask = e.stateMask;
82     this.count = e.count;
83 }
84
85 /**
86  * Returns a string containing a concise, human-readable
87  * description of the receiver.
88  *
89  * @return a string representation of the event
90  */

91 public String JavaDoc toString() {
92     String JavaDoc string = super.toString ();
93     return string.substring (0, string.length() - 1) // remove trailing '}'
94
+ " button=" + button
95         + " stateMask=" + stateMask
96         + " x=" + x
97         + " y=" + y
98         + " count=" + count
99         + "}";
100 }
101 }
102
Popular Tags