Subversion Repository Public Repository

litesoft

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

Diff revisions: vs.
  @@ -1,175 +1,175 @@
1 - /*
2 - * Copyright 2008 Google Inc.
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 - * use this file except in compliance with the License. You may obtain a copy of
6 - * the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 - * License for the specific language governing permissions and limitations under
14 - * the License.
15 - */
16 -
17 - package com.google.gwt.gen2.event.dom.client;
18 -
19 - import com.google.gwt.user.client.*;
20 - import com.google.gwt.user.client.ui.*;
21 -
22 - /**
23 - * Key up and key down are both events based upon a given key code.
24 - *
25 - * @deprecated use the com.google.gwt.event.dom.client classes instead
26 - */
27 - @Deprecated
28 - public abstract class KeyCodeEvent extends KeyEvent {
29 -
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 - *
135 - * @return if it is an arrow key code
136 - */
137 - public boolean isArrowKeyCode( int code ) {
138 - switch ( code ) {
139 - case KeyboardListener.KEY_DOWN:
140 - case KeyboardListener.KEY_RIGHT:
141 - case KeyboardListener.KEY_UP:
142 - case KeyboardListener.KEY_LEFT:
143 - return true;
144 - default:
145 - return false;
146 - }
147 - }
148 -
149 - /**
150 - * Is this a key down?
151 - *
152 - * @return whether this is a down arrow key event
153 - */
154 - public boolean isDownKeyCode() {
155 - return getKeyCode() == KEY_DOWN;
156 - }
157 -
158 - /**
159 - * Is this a key left?
160 - *
161 - * @return whether this is a left arrow key event
162 - */
163 - public boolean isLeftKeyCode() {
164 - return getKeyCode() == KEY_LEFT;
165 - }
166 -
167 - /**
168 - * Is this a key right?
169 - *
170 - * @return whether this is a right arrow key event
171 - */
172 - public boolean isRightKeyCode() {
173 - return getKeyCode() == KEY_RIGHT;
174 - }
175 - }
1 + /*
2 + * Copyright 2008 Google Inc.
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 + * use this file except in compliance with the License. You may obtain a copy of
6 + * the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 + * License for the specific language governing permissions and limitations under
14 + * the License.
15 + */
16 +
17 + package com.google.gwt.gen2.event.dom.client;
18 +
19 + import com.google.gwt.user.client.*;
20 + import com.google.gwt.user.client.ui.*;
21 +
22 + /**
23 + * Key up and key down are both events based upon a given key code.
24 + *
25 + * @deprecated use the com.google.gwt.event.dom.client classes instead
26 + */
27 + @Deprecated
28 + public abstract class KeyCodeEvent extends KeyEvent {
29 +
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 + *
135 + * @return if it is an arrow key code
136 + */
137 + public boolean isArrowKeyCode( int code ) {
138 + switch ( code ) {
139 + case KeyboardListener.KEY_DOWN:
140 + case KeyboardListener.KEY_RIGHT:
141 + case KeyboardListener.KEY_UP:
142 + case KeyboardListener.KEY_LEFT:
143 + return true;
144 + default:
145 + return false;
146 + }
147 + }
148 +
149 + /**
150 + * Is this a key down?
151 + *
152 + * @return whether this is a down arrow key event
153 + */
154 + public boolean isDownKeyCode() {
155 + return getKeyCode() == KEY_DOWN;
156 + }
157 +
158 + /**
159 + * Is this a key left?
160 + *
161 + * @return whether this is a left arrow key event
162 + */
163 + public boolean isLeftKeyCode() {
164 + return getKeyCode() == KEY_LEFT;
165 + }
166 +
167 + /**
168 + * Is this a key right?
169 + *
170 + * @return whether this is a right arrow key event
171 + */
172 + public boolean isRightKeyCode() {
173 + return getKeyCode() == KEY_RIGHT;
174 + }
175 + }