| 1 |
/******************************************************************************* |
|---|
| 2 |
* Copyright (c) 2000, 2008 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 |
* Port to the D programming language: |
|---|
| 11 |
* Frank Benoit <benoit@tionex.de> |
|---|
| 12 |
*******************************************************************************/ |
|---|
| 13 |
module dwt.events.MouseEvent; |
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
import dwt.widgets.Event; |
|---|
| 17 |
import dwt.events.TypedEvent; |
|---|
| 18 |
|
|---|
| 19 |
import tango.text.convert.Format; |
|---|
| 20 |
import dwt.dwthelper.utils; |
|---|
| 21 |
|
|---|
| 22 |
/** |
|---|
| 23 |
* Instances of this class are sent whenever mouse |
|---|
| 24 |
* related actions occur. This includes mouse buttons |
|---|
| 25 |
* being pressed and released, the mouse pointer being |
|---|
| 26 |
* moved and the mouse pointer crossing widget boundaries. |
|---|
| 27 |
* <p> |
|---|
| 28 |
* Note: The <code>button</code> field is an integer that |
|---|
| 29 |
* represents the mouse button number. This is not the same |
|---|
| 30 |
* as the <code>DWT</code> mask constants <code>BUTTONx</code>. |
|---|
| 31 |
* </p> |
|---|
| 32 |
* |
|---|
| 33 |
* @see MouseListener |
|---|
| 34 |
* @see MouseMoveListener |
|---|
| 35 |
* @see MouseTrackListener |
|---|
| 36 |
* @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> |
|---|
| 37 |
*/ |
|---|
| 38 |
|
|---|
| 39 |
public class MouseEvent : TypedEvent { |
|---|
| 40 |
|
|---|
| 41 |
/** |
|---|
| 42 |
* the button that was pressed or released; 1 for the |
|---|
| 43 |
* first button, 2 for the second button, and 3 for the |
|---|
| 44 |
* third button, etc. |
|---|
| 45 |
*/ |
|---|
| 46 |
public int button; |
|---|
| 47 |
|
|---|
| 48 |
/** |
|---|
| 49 |
* the state of the keyboard modifier keys at the time |
|---|
| 50 |
* the event was generated |
|---|
| 51 |
*/ |
|---|
| 52 |
public int stateMask; |
|---|
| 53 |
|
|---|
| 54 |
/** |
|---|
| 55 |
* the widget-relative, x coordinate of the pointer |
|---|
| 56 |
* at the time the mouse button was pressed or released |
|---|
| 57 |
*/ |
|---|
| 58 |
public int x; |
|---|
| 59 |
|
|---|
| 60 |
/** |
|---|
| 61 |
* the widget-relative, y coordinate of the pointer |
|---|
| 62 |
* at the time the mouse button was pressed or released |
|---|
| 63 |
*/ |
|---|
| 64 |
public int y; |
|---|
| 65 |
|
|---|
| 66 |
/** |
|---|
| 67 |
* the number times the mouse has been clicked, as defined |
|---|
| 68 |
* by the operating system; 1 for the first click, 2 for the |
|---|
| 69 |
* second click and so on. |
|---|
| 70 |
* |
|---|
| 71 |
* @since 3.3 |
|---|
| 72 |
*/ |
|---|
| 73 |
public int count; |
|---|
| 74 |
|
|---|
| 75 |
//static final long serialVersionUID = 3257288037011566898L; |
|---|
| 76 |
|
|---|
| 77 |
/** |
|---|
| 78 |
* Constructs a new instance of this class based on the |
|---|
| 79 |
* information in the given untyped event. |
|---|
| 80 |
* |
|---|
| 81 |
* @param e the untyped event containing the information |
|---|
| 82 |
*/ |
|---|
| 83 |
public this(Event e) { |
|---|
| 84 |
super(e); |
|---|
| 85 |
this.x = e.x; |
|---|
| 86 |
this.y = e.y; |
|---|
| 87 |
this.button = e.button; |
|---|
| 88 |
this.stateMask = e.stateMask; |
|---|
| 89 |
this.count = e.count; |
|---|
| 90 |
} |
|---|
| 91 |
|
|---|
| 92 |
/** |
|---|
| 93 |
* Returns a string containing a concise, human-readable |
|---|
| 94 |
* description of the receiver. |
|---|
| 95 |
* |
|---|
| 96 |
* @return a string representation of the event |
|---|
| 97 |
*/ |
|---|
| 98 |
public override String toString() { |
|---|
| 99 |
return Format( "{} button={} stateMask={} x={} y={} count={}}", |
|---|
| 100 |
super.toString[ 0 .. $-1 ], |
|---|
| 101 |
button, stateMask, x, y, count ); |
|---|
| 102 |
} |
|---|
| 103 |
} |
|---|