comparison dwt/events/KeyEvent.d @ 9:ad2b69216039

moved org.eclipse.swt to dwt
author Frank Benoit <benoit@tionex.de>
date Sat, 05 Jan 2008 17:39:49 +0100
parents org/eclipse/swt/events/KeyEvent.d@088b30eabff3
children 63c023465156
comparison
equal deleted inserted replaced
8:a1f832ca7d17 9:ad2b69216039
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 *******************************************************************************/
11 module org.eclipse.swt.events.KeyEvent;
12
13
14 import org.eclipse.swt.widgets.Event;
15 import org.eclipse.swt.events.TypedEvent;
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 *
58 * @see org.eclipse.swt.SWT
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 *
67 * @see org.eclipse.swt.SWT
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 }