|
@@ -1,102 +1,102 @@ |
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 |
|
- |
package com.google.gwt.gen2.event.dom.client; |
17 |
|
- |
|
18 |
|
- |
import com.google.gwt.user.client.*; |
19 |
|
- |
|
20 |
|
- |
/** |
21 |
|
- |
* Base class for Key events. The native keyboard events are somewhat a mess |
22 |
|
- |
* (http://www.quirksmode.org/js/keys.html), we do some trivial normalization |
23 |
|
- |
* here, but do not attempt any complex patching, so user be warned. |
24 |
|
- |
* |
25 |
|
- |
* @deprecated use the com.google.gwt.event.dom.client classes instead |
26 |
|
- |
*/ |
27 |
|
- |
@Deprecated |
28 |
|
- |
public abstract class KeyEvent extends DomEvent { |
29 |
|
- |
|
30 |
|
- |
/** |
31 |
|
- |
* Alt modifier. |
32 |
|
- |
*/ |
33 |
|
- |
public static final int MODIFIER_ALT = 4; |
34 |
|
- |
/** |
35 |
|
- |
* Control modifier. |
36 |
|
- |
*/ |
37 |
|
- |
public static final int MODIFIER_CTRL = 2; |
38 |
|
- |
/** |
39 |
|
- |
* Meta modifier. |
40 |
|
- |
*/ |
41 |
|
- |
public static final int MODIFIER_META = 8; |
42 |
|
- |
/** |
43 |
|
- |
* Shift modifier. |
44 |
|
- |
*/ |
45 |
|
- |
public static final int MODIFIER_SHIFT = 1; |
46 |
|
- |
|
47 |
|
- |
/** |
48 |
|
- |
* Constructor. |
49 |
|
- |
* |
50 |
|
- |
* @param nativeEvent the wrapped native event |
51 |
|
- |
*/ |
52 |
|
- |
protected KeyEvent( Event nativeEvent ) { |
53 |
|
- |
super( nativeEvent ); |
54 |
|
- |
} |
55 |
|
- |
|
56 |
|
- |
/** |
57 |
|
- |
* Gets the key modifiers associated with this event. |
58 |
|
- |
* |
59 |
|
- |
* @return the modifiers as defined in {@link KeyCodeEvent}. |
60 |
|
- |
*/ |
61 |
|
- |
public int getKeyModifiers() { |
62 |
|
- |
Event event = getNativeEvent(); |
63 |
|
- |
return (DOM.eventGetShiftKey( event ) ? MODIFIER_SHIFT : 0) | (DOM.eventGetMetaKey( event ) ? MODIFIER_META : 0) | |
64 |
|
- |
(DOM.eventGetCtrlKey( event ) ? MODIFIER_CTRL : 0) | (DOM.eventGetAltKey( event ) ? MODIFIER_ALT : 0); |
65 |
|
- |
} |
66 |
|
- |
|
67 |
|
- |
/** |
68 |
|
- |
* Is the <code>alt</code> key down? |
69 |
|
- |
* |
70 |
|
- |
* @return whether the alt key is down |
71 |
|
- |
*/ |
72 |
|
- |
public boolean isAltKeyDown() { |
73 |
|
- |
return getNativeEvent().getAltKey(); |
74 |
|
- |
} |
75 |
|
- |
|
76 |
|
- |
/** |
77 |
|
- |
* Gets the key-repeat state of this event. |
78 |
|
- |
* |
79 |
|
- |
* @return <code>true</code> if this key event was an auto-repeat |
80 |
|
- |
*/ |
81 |
|
- |
public boolean isAutoRepeat() { |
82 |
|
- |
return getNativeEvent().getRepeat(); |
83 |
|
- |
} |
84 |
|
- |
|
85 |
|
- |
/** |
86 |
|
- |
* Is the <code>control</code> key down? |
87 |
|
- |
* |
88 |
|
- |
* @return whether the control key is down |
89 |
|
- |
*/ |
90 |
|
- |
public boolean isControlKeyDown() { |
91 |
|
- |
return getNativeEvent().getCtrlKey(); |
92 |
|
- |
} |
93 |
|
- |
|
94 |
|
- |
/** |
95 |
|
- |
* Is the <code>shift</code> key down? |
96 |
|
- |
* |
97 |
|
- |
* @return whether the shift key is down |
98 |
|
- |
*/ |
99 |
|
- |
public boolean isShiftKeyDown() { |
100 |
|
- |
return getNativeEvent().getShiftKey(); |
101 |
|
- |
} |
102 |
|
- |
} |
|
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 |
+ |
package com.google.gwt.gen2.event.dom.client; |
|
17 |
+ |
|
|
18 |
+ |
import com.google.gwt.user.client.*; |
|
19 |
+ |
|
|
20 |
+ |
/** |
|
21 |
+ |
* Base class for Key events. The native keyboard events are somewhat a mess |
|
22 |
+ |
* (http://www.quirksmode.org/js/keys.html), we do some trivial normalization |
|
23 |
+ |
* here, but do not attempt any complex patching, so user be warned. |
|
24 |
+ |
* |
|
25 |
+ |
* @deprecated use the com.google.gwt.event.dom.client classes instead |
|
26 |
+ |
*/ |
|
27 |
+ |
@Deprecated |
|
28 |
+ |
public abstract class KeyEvent extends DomEvent { |
|
29 |
+ |
|
|
30 |
+ |
/** |
|
31 |
+ |
* Alt modifier. |
|
32 |
+ |
*/ |
|
33 |
+ |
public static final int MODIFIER_ALT = 4; |
|
34 |
+ |
/** |
|
35 |
+ |
* Control modifier. |
|
36 |
+ |
*/ |
|
37 |
+ |
public static final int MODIFIER_CTRL = 2; |
|
38 |
+ |
/** |
|
39 |
+ |
* Meta modifier. |
|
40 |
+ |
*/ |
|
41 |
+ |
public static final int MODIFIER_META = 8; |
|
42 |
+ |
/** |
|
43 |
+ |
* Shift modifier. |
|
44 |
+ |
*/ |
|
45 |
+ |
public static final int MODIFIER_SHIFT = 1; |
|
46 |
+ |
|
|
47 |
+ |
/** |
|
48 |
+ |
* Constructor. |
|
49 |
+ |
* |
|
50 |
+ |
* @param nativeEvent the wrapped native event |
|
51 |
+ |
*/ |
|
52 |
+ |
protected KeyEvent( Event nativeEvent ) { |
|
53 |
+ |
super( nativeEvent ); |
|
54 |
+ |
} |
|
55 |
+ |
|
|
56 |
+ |
/** |
|
57 |
+ |
* Gets the key modifiers associated with this event. |
|
58 |
+ |
* |
|
59 |
+ |
* @return the modifiers as defined in {@link KeyCodeEvent}. |
|
60 |
+ |
*/ |
|
61 |
+ |
public int getKeyModifiers() { |
|
62 |
+ |
Event event = getNativeEvent(); |
|
63 |
+ |
return (DOM.eventGetShiftKey( event ) ? MODIFIER_SHIFT : 0) | (DOM.eventGetMetaKey( event ) ? MODIFIER_META : 0) | |
|
64 |
+ |
(DOM.eventGetCtrlKey( event ) ? MODIFIER_CTRL : 0) | (DOM.eventGetAltKey( event ) ? MODIFIER_ALT : 0); |
|
65 |
+ |
} |
|
66 |
+ |
|
|
67 |
+ |
/** |
|
68 |
+ |
* Is the <code>alt</code> key down? |
|
69 |
+ |
* |
|
70 |
+ |
* @return whether the alt key is down |
|
71 |
+ |
*/ |
|
72 |
+ |
public boolean isAltKeyDown() { |
|
73 |
+ |
return getNativeEvent().getAltKey(); |
|
74 |
+ |
} |
|
75 |
+ |
|
|
76 |
+ |
/** |
|
77 |
+ |
* Gets the key-repeat state of this event. |
|
78 |
+ |
* |
|
79 |
+ |
* @return <code>true</code> if this key event was an auto-repeat |
|
80 |
+ |
*/ |
|
81 |
+ |
public boolean isAutoRepeat() { |
|
82 |
+ |
return getNativeEvent().getRepeat(); |
|
83 |
+ |
} |
|
84 |
+ |
|
|
85 |
+ |
/** |
|
86 |
+ |
* Is the <code>control</code> key down? |
|
87 |
+ |
* |
|
88 |
+ |
* @return whether the control key is down |
|
89 |
+ |
*/ |
|
90 |
+ |
public boolean isControlKeyDown() { |
|
91 |
+ |
return getNativeEvent().getCtrlKey(); |
|
92 |
+ |
} |
|
93 |
+ |
|
|
94 |
+ |
/** |
|
95 |
+ |
* Is the <code>shift</code> key down? |
|
96 |
+ |
* |
|
97 |
+ |
* @return whether the shift key is down |
|
98 |
+ |
*/ |
|
99 |
+ |
public boolean isShiftKeyDown() { |
|
100 |
+ |
return getNativeEvent().getShiftKey(); |
|
101 |
+ |
} |
|
102 |
+ |
} |