Mercurial > projects > dwt-linux
annotate dwt/events/KeyEvent.d @ 10:63c023465156
moved from org.eclipse.swt to dwt
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 05 Jan 2008 17:58:37 +0100 |
parents | ad2b69216039 |
children | 8cec8f536af3 |
rev | line source |
---|---|
1 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2006 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 *******************************************************************************/ | |
10
63c023465156
moved from org.eclipse.swt to dwt
Frank Benoit <benoit@tionex.de>
parents:
9
diff
changeset
|
11 module dwt.events.KeyEvent; |
1 | 12 |
13 | |
10
63c023465156
moved from org.eclipse.swt to dwt
Frank Benoit <benoit@tionex.de>
parents:
9
diff
changeset
|
14 import dwt.widgets.Event; |
63c023465156
moved from org.eclipse.swt to dwt
Frank Benoit <benoit@tionex.de>
parents:
9
diff
changeset
|
15 import dwt.events.TypedEvent; |
1 | 16 |
17 import tango.text.convert.Format; | |
18 | |
19 /** | |
20 * Instances of this class are sent as a result of | |
21 * keys being pressed and released on the keyboard. | |
22 * <p> | |
23 * When a key listener is added to a control, the control | |
24 * will take part in widget traversal. By default, all | |
25 * traversal keys (such as the tab key and so on) are | |
26 * delivered to the control. In order for a control to take | |
27 * part in traversal, it should listen for traversal events. | |
28 * Otherwise, the user can traverse into a control but not | |
29 * out. Note that native controls such as table and tree | |
30 * implement key traversal in the operating system. It is | |
31 * not necessary to add traversal listeners for these controls, | |
32 * unless you want to override the default traversal. | |
33 * </p> | |
34 * @see KeyListener | |
35 * @see TraverseListener | |
36 */ | |
37 | |
38 public class KeyEvent : TypedEvent { | |
39 | |
40 /** | |
41 * the character represented by the key that was typed. | |
42 * This is the final character that results after all modifiers have been | |
43 * applied. For example, when the user types Ctrl+A, the character value | |
44 * is 0x01. It is important that applications do not attempt to modify the | |
45 * character value based on a stateMask (such as SWT.CTRL) or the resulting | |
46 * character will not be correct. | |
47 */ | |
48 public char character; | |
49 | |
50 /** | |
51 * the key code of the key that was typed, | |
52 * as defined by the key code constants in class <code>SWT</code>. | |
53 * When the character field of the event is ambiguous, this field | |
54 * contains the unicode value of the original character. For example, | |
55 * typing Ctrl+M or Return both result in the character '\r' but the | |
56 * keyCode field will also contain '\r' when Return was typed. | |
57 * | |
10
63c023465156
moved from org.eclipse.swt to dwt
Frank Benoit <benoit@tionex.de>
parents:
9
diff
changeset
|
58 * @see dwt.SWT |
1 | 59 */ |
60 public int keyCode; | |
61 | |
62 /** | |
63 * the state of the keyboard modifier keys at the time | |
64 * the event was generated, as defined by the key code | |
65 * constants in class <code>SWT</code>. | |
66 * | |
10
63c023465156
moved from org.eclipse.swt to dwt
Frank Benoit <benoit@tionex.de>
parents:
9
diff
changeset
|
67 * @see dwt.SWT |
1 | 68 */ |
69 public int stateMask; | |
70 | |
71 /** | |
72 * A flag indicating whether the operation should be allowed. | |
73 * Setting this field to <code>false</code> will cancel the operation. | |
74 */ | |
75 public bool doit; | |
76 | |
77 static final long serialVersionUID = 3256442491011412789L; | |
78 | |
79 /** | |
80 * Constructs a new instance of this class based on the | |
81 * information in the given untyped event. | |
82 * | |
83 * @param e the untyped event containing the information | |
84 */ | |
85 public this(Event e) { | |
86 super(e); | |
87 this.character = e.character; | |
88 this.keyCode = e.keyCode; | |
89 this.stateMask = e.stateMask; | |
90 this.doit = e.doit; | |
91 } | |
92 | |
93 /** | |
94 * Returns a string containing a concise, human-readable | |
95 * description of the receiver. | |
96 * | |
97 * @return a string representation of the event | |
98 */ | |
99 public char[] toString() { | |
100 return Format( "{} character={} keyCode={} stateMask={} doit={}}", | |
101 super.toString[ 0 .. $-2 ], | |
102 character, keyCode, stateMask, doit ); | |
103 } | |
104 } |