Subversion Repository Public Repository

litesoft

Diff Revisions 282 vs 475 for /trunk/Java/GWT/Client/src/com/google/gwt/gen2/event/dom/client/KeyCodeEvent.java

Diff revisions: vs.
  @@ -16,160 +16,169 @@
16 16
17 17 package com.google.gwt.gen2.event.dom.client;
18 18
19 - import com.google.gwt.user.client.Event;
20 - import com.google.gwt.user.client.ui.KeyboardListener;
19 + import com.google.gwt.user.client.*;
20 + import com.google.gwt.user.client.ui.*;
21 21
22 22 /**
23 23 * Key up and key down are both events based upon a given key code.
24 - *
24 + *
25 25 * @deprecated use the com.google.gwt.event.dom.client classes instead
26 26 */
27 27 @Deprecated
28 - public abstract class KeyCodeEvent extends KeyEvent {
28 + public abstract class KeyCodeEvent extends KeyEvent
29 + {
29 30
30 - /**
31 - * Alt key code.
32 - */
33 - public static final int KEY_ALT = 18;
34 -
35 - /**
36 - * Backspace key code.
37 - */
38 - public static final int KEY_BACKSPACE = 8;
39 -
40 - /**
41 - * Control key code.
42 - */
43 - public static final int KEY_CTRL = 17;
44 -
45 - /**
46 - * Delete key code.
47 - */
48 - public static final int KEY_DELETE = 46;
49 -
50 - /**
51 - * Down arrow code.
52 - */
53 - public static final int KEY_DOWN = 40;
54 -
55 - /**
56 - * End key code.
57 - */
58 - public static final int KEY_END = 35;
59 - /**
60 - * Enter key code.
61 - */
62 - public static final int KEY_ENTER = 13;
63 - /**
64 - * Escape key code.
65 - */
66 - public static final int KEY_ESCAPE = 27;
67 - /**
68 - * Home key code.
69 - */
70 - public static final int KEY_HOME = 36;
71 - /**
72 - * Left key code.
73 - */
74 - public static final int KEY_LEFT = 37;
75 - /**
76 - * Page down key code.
77 - */
78 - public static final int KEY_PAGEDOWN = 34;
79 - /**
80 - * Page up key code.
81 - */
82 - public static final int KEY_PAGEUP = 33;
83 - /**
84 - * Right arrow key code.
85 - */
86 - public static final int KEY_RIGHT = 39;
87 -
88 - /**
89 - * Shift key code.
90 - */
91 - public static final int KEY_SHIFT = 16;
92 - /**
93 - * Tab key code.
94 - */
95 - public static final int KEY_TAB = 9;
96 -
97 - /**
98 - * Up Arrow key code.
99 - */
100 - public static final int KEY_UP = 38;
101 -
102 - /**
103 - * Constructor.
104 - *
105 - * @param nativeEvent the wrapped native event
106 - */
107 - protected KeyCodeEvent(Event nativeEvent) {
108 - super(nativeEvent);
109 - }
110 -
111 - /**
112 - * Gets the current key code.
113 - *
114 - * @return the key code
115 - */
116 - public int getKeyCode() {
117 - return getNativeEvent().getKeyCode();
118 - }
119 -
120 - /**
121 - * Is the key code alpha-numeric (i.e. A-z or 0-9)?
122 - *
123 - * @return is the key code alpha numeric.
124 - */
125 - public boolean isAlphaNumeric() {
126 - int keycode = getKeyCode();
127 - return (48 <= keycode && keycode <= 57) || (65 <= keycode && keycode <= 90);
128 - }
129 -
130 - /**
131 - * Does the key code represent an arrow key?
132 - *
133 - * @param code the key code
134 - * @return if it is an arrow key code
135 - */
136 - public boolean isArrowKeyCode(int code) {
137 - switch (code) {
138 - case KeyboardListener.KEY_DOWN:
139 - case KeyboardListener.KEY_RIGHT:
140 - case KeyboardListener.KEY_UP:
141 - case KeyboardListener.KEY_LEFT:
142 - return true;
143 - default:
144 - return false;
145 - }
146 - }
147 -
148 - /**
149 - * Is this a key down?
150 - *
151 - * @return whether this is a down arrow key event
152 - */
153 - public boolean isDownKeyCode() {
154 - return getKeyCode() == KEY_DOWN;
155 - }
156 -
157 - /**
158 - * Is this a key left?
159 - *
160 - * @return whether this is a left arrow key event
161 - */
162 - public boolean isLeftKeyCode() {
163 - return getKeyCode() == KEY_LEFT;
164 - }
165 -
166 - /**
167 - * Is this a key right?
168 - *
169 - * @return whether this is a right arrow key event
170 - */
171 - public boolean isRightKeyCode() {
172 - return getKeyCode() == KEY_RIGHT;
173 - }
31 + /**
32 + * Alt key code.
33 + */
34 + public static final int KEY_ALT = 18;
35 +
36 + /**
37 + * Backspace key code.
38 + */
39 + public static final int KEY_BACKSPACE = 8;
40 +
41 + /**
42 + * Control key code.
43 + */
44 + public static final int KEY_CTRL = 17;
45 +
46 + /**
47 + * Delete key code.
48 + */
49 + public static final int KEY_DELETE = 46;
50 +
51 + /**
52 + * Down arrow code.
53 + */
54 + public static final int KEY_DOWN = 40;
55 +
56 + /**
57 + * End key code.
58 + */
59 + public static final int KEY_END = 35;
60 + /**
61 + * Enter key code.
62 + */
63 + public static final int KEY_ENTER = 13;
64 + /**
65 + * Escape key code.
66 + */
67 + public static final int KEY_ESCAPE = 27;
68 + /**
69 + * Home key code.
70 + */
71 + public static final int KEY_HOME = 36;
72 + /**
73 + * Left key code.
74 + */
75 + public static final int KEY_LEFT = 37;
76 + /**
77 + * Page down key code.
78 + */
79 + public static final int KEY_PAGEDOWN = 34;
80 + /**
81 + * Page up key code.
82 + */
83 + public static final int KEY_PAGEUP = 33;
84 + /**
85 + * Right arrow key code.
86 + */
87 + public static final int KEY_RIGHT = 39;
88 +
89 + /**
90 + * Shift key code.
91 + */
92 + public static final int KEY_SHIFT = 16;
93 + /**
94 + * Tab key code.
95 + */
96 + public static final int KEY_TAB = 9;
97 +
98 + /**
99 + * Up Arrow key code.
100 + */
101 + public static final int KEY_UP = 38;
102 +
103 + /**
104 + * Constructor.
105 + *
106 + * @param nativeEvent the wrapped native event
107 + */
108 + protected KeyCodeEvent( Event nativeEvent )
109 + {
110 + super( nativeEvent );
111 + }
112 +
113 + /**
114 + * Gets the current key code.
115 + *
116 + * @return the key code
117 + */
118 + public int getKeyCode()
119 + {
120 + return getNativeEvent().getKeyCode();
121 + }
122 +
123 + /**
124 + * Is the key code alpha-numeric (i.e. A-z or 0-9)?
125 + *
126 + * @return is the key code alpha numeric.
127 + */
128 + public boolean isAlphaNumeric()
129 + {
130 + int keycode = getKeyCode();
131 + return (48 <= keycode && keycode <= 57) || (65 <= keycode && keycode <= 90);
132 + }
133 +
134 + /**
135 + * Does the key code represent an arrow key?
136 + *
137 + * @param code the key code
138 + *
139 + * @return if it is an arrow key code
140 + */
141 + public boolean isArrowKeyCode( int code )
142 + {
143 + switch ( code )
144 + {
145 + case KeyboardListener.KEY_DOWN:
146 + case KeyboardListener.KEY_RIGHT:
147 + case KeyboardListener.KEY_UP:
148 + case KeyboardListener.KEY_LEFT:
149 + return true;
150 + default:
151 + return false;
152 + }
153 + }
154 +
155 + /**
156 + * Is this a key down?
157 + *
158 + * @return whether this is a down arrow key event
159 + */
160 + public boolean isDownKeyCode()
161 + {
162 + return getKeyCode() == KEY_DOWN;
163 + }
174 164
165 + /**
166 + * Is this a key left?
167 + *
168 + * @return whether this is a left arrow key event
169 + */
170 + public boolean isLeftKeyCode()
171 + {
172 + return getKeyCode() == KEY_LEFT;
173 + }
174 +
175 + /**
176 + * Is this a key right?
177 + *
178 + * @return whether this is a right arrow key event
179 + */
180 + public boolean isRightKeyCode()
181 + {
182 + return getKeyCode() == KEY_RIGHT;
183 + }
175 184 }