|
@@ -1,153 +1,153 @@ |
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.gen2.event.shared.*; |
19 |
|
- |
import com.google.gwt.user.client.*; |
20 |
|
- |
|
21 |
|
- |
/** |
22 |
|
- |
* Abstract class representing mouse events. |
23 |
|
- |
* |
24 |
|
- |
* @param <T> event handler type |
25 |
|
- |
* |
26 |
|
- |
* @deprecated use the com.google.gwt.event.dom.client classes instead |
27 |
|
- |
*/ |
28 |
|
- |
@Deprecated |
29 |
|
- |
public abstract class MouseEvent<T extends EventHandler> extends DomEvent { |
30 |
|
- |
|
31 |
|
- |
/** |
32 |
|
- |
* The native Dom button codes. |
33 |
|
- |
*/ |
34 |
|
- |
public enum Button { |
35 |
|
- |
/** |
36 |
|
- |
* Left button. |
37 |
|
- |
*/ |
38 |
|
- |
LEFT, |
39 |
|
- |
/** |
40 |
|
- |
* Middle button. |
41 |
|
- |
*/ |
42 |
|
- |
MIDDLE, |
43 |
|
- |
/** |
44 |
|
- |
* Right button. |
45 |
|
- |
*/ |
46 |
|
- |
RIGHT; |
47 |
|
- |
|
48 |
|
- |
/** |
49 |
|
- |
* Gets the button codes. |
50 |
|
- |
* |
51 |
|
- |
* @param buttonCode the button code |
52 |
|
- |
* |
53 |
|
- |
* @return which button |
54 |
|
- |
*/ |
55 |
|
- |
public static Button valueOf( int buttonCode ) { |
56 |
|
- |
switch ( buttonCode ) { |
57 |
|
- |
case Event.BUTTON_LEFT: |
58 |
|
- |
return LEFT; |
59 |
|
- |
case Event.BUTTON_RIGHT: |
60 |
|
- |
return RIGHT; |
61 |
|
- |
case Event.BUTTON_MIDDLE: |
62 |
|
- |
return MIDDLE; |
63 |
|
- |
default: |
64 |
|
- |
throw new IllegalStateException( "Unknown button code " + buttonCode ); |
65 |
|
- |
} |
66 |
|
- |
} |
67 |
|
- |
} |
68 |
|
- |
|
69 |
|
- |
MouseEvent( Event e ) { |
70 |
|
- |
super( e ); |
71 |
|
- |
} |
72 |
|
- |
|
73 |
|
- |
/** |
74 |
|
- |
* Gets the button value. |
75 |
|
- |
* |
76 |
|
- |
* @return gets the button value. |
77 |
|
- |
*/ |
78 |
|
- |
public Button getButton() { |
79 |
|
- |
return Button.valueOf( getNativeEvent().getButton() ); |
80 |
|
- |
} |
81 |
|
- |
|
82 |
|
- |
/** |
83 |
|
- |
* Gets the mouse x-position within the browser window's client area. |
84 |
|
- |
* |
85 |
|
- |
* @return the mouse x-position |
86 |
|
- |
*/ |
87 |
|
- |
public int getClientX() { |
88 |
|
- |
return getNativeEvent().getClientX(); |
89 |
|
- |
} |
90 |
|
- |
|
91 |
|
- |
/** |
92 |
|
- |
* Gets the mouse y-position within the browser window's client area. |
93 |
|
- |
* |
94 |
|
- |
* @return the mouse y-position |
95 |
|
- |
*/ |
96 |
|
- |
public int getClientY() { |
97 |
|
- |
return getNativeEvent().getClientY(); |
98 |
|
- |
} |
99 |
|
- |
|
100 |
|
- |
/** |
101 |
|
- |
* Gets the mouse x-position on the user's display. |
102 |
|
- |
* |
103 |
|
- |
* @return the mouse x-position |
104 |
|
- |
*/ |
105 |
|
- |
public int getScreenX() { |
106 |
|
- |
return getNativeEvent().getScreenX(); |
107 |
|
- |
} |
108 |
|
- |
|
109 |
|
- |
/** |
110 |
|
- |
* Gets the mouse y-position on the user's display. |
111 |
|
- |
* |
112 |
|
- |
* @return the mouse y-position |
113 |
|
- |
*/ |
114 |
|
- |
public int getScreenY() { |
115 |
|
- |
return getNativeEvent().getScreenY(); |
116 |
|
- |
} |
117 |
|
- |
|
118 |
|
- |
/** |
119 |
|
- |
* Is <code>alt</code> key down. |
120 |
|
- |
* |
121 |
|
- |
* @return whether the alt key is down |
122 |
|
- |
*/ |
123 |
|
- |
public boolean isAltKeyDown() { |
124 |
|
- |
return getNativeEvent().getAltKey(); |
125 |
|
- |
} |
126 |
|
- |
|
127 |
|
- |
/** |
128 |
|
- |
* Is <code>control</code> key down. |
129 |
|
- |
* |
130 |
|
- |
* @return whether the control key is down |
131 |
|
- |
*/ |
132 |
|
- |
public boolean isControlKeyDown() { |
133 |
|
- |
return getNativeEvent().getCtrlKey(); |
134 |
|
- |
} |
135 |
|
- |
|
136 |
|
- |
/** |
137 |
|
- |
* Is <code>meta</code> key down. |
138 |
|
- |
* |
139 |
|
- |
* @return whether the meta key is down |
140 |
|
- |
*/ |
141 |
|
- |
public boolean isMetaKeyDown() { |
142 |
|
- |
return getNativeEvent().getMetaKey(); |
143 |
|
- |
} |
144 |
|
- |
|
145 |
|
- |
/** |
146 |
|
- |
* Is <code>shift</code> key down. |
147 |
|
- |
* |
148 |
|
- |
* @return whether the shift key is down |
149 |
|
- |
*/ |
150 |
|
- |
public boolean isShiftKeyDown() { |
151 |
|
- |
return getNativeEvent().getShiftKey(); |
152 |
|
- |
} |
153 |
|
- |
} |
|
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.gen2.event.shared.*; |
|
19 |
+ |
import com.google.gwt.user.client.*; |
|
20 |
+ |
|
|
21 |
+ |
/** |
|
22 |
+ |
* Abstract class representing mouse events. |
|
23 |
+ |
* |
|
24 |
+ |
* @param <T> event handler type |
|
25 |
+ |
* |
|
26 |
+ |
* @deprecated use the com.google.gwt.event.dom.client classes instead |
|
27 |
+ |
*/ |
|
28 |
+ |
@Deprecated |
|
29 |
+ |
public abstract class MouseEvent<T extends EventHandler> extends DomEvent { |
|
30 |
+ |
|
|
31 |
+ |
/** |
|
32 |
+ |
* The native Dom button codes. |
|
33 |
+ |
*/ |
|
34 |
+ |
public enum Button { |
|
35 |
+ |
/** |
|
36 |
+ |
* Left button. |
|
37 |
+ |
*/ |
|
38 |
+ |
LEFT, |
|
39 |
+ |
/** |
|
40 |
+ |
* Middle button. |
|
41 |
+ |
*/ |
|
42 |
+ |
MIDDLE, |
|
43 |
+ |
/** |
|
44 |
+ |
* Right button. |
|
45 |
+ |
*/ |
|
46 |
+ |
RIGHT; |
|
47 |
+ |
|
|
48 |
+ |
/** |
|
49 |
+ |
* Gets the button codes. |
|
50 |
+ |
* |
|
51 |
+ |
* @param buttonCode the button code |
|
52 |
+ |
* |
|
53 |
+ |
* @return which button |
|
54 |
+ |
*/ |
|
55 |
+ |
public static Button valueOf( int buttonCode ) { |
|
56 |
+ |
switch ( buttonCode ) { |
|
57 |
+ |
case Event.BUTTON_LEFT: |
|
58 |
+ |
return LEFT; |
|
59 |
+ |
case Event.BUTTON_RIGHT: |
|
60 |
+ |
return RIGHT; |
|
61 |
+ |
case Event.BUTTON_MIDDLE: |
|
62 |
+ |
return MIDDLE; |
|
63 |
+ |
default: |
|
64 |
+ |
throw new IllegalStateException( "Unknown button code " + buttonCode ); |
|
65 |
+ |
} |
|
66 |
+ |
} |
|
67 |
+ |
} |
|
68 |
+ |
|
|
69 |
+ |
MouseEvent( Event e ) { |
|
70 |
+ |
super( e ); |
|
71 |
+ |
} |
|
72 |
+ |
|
|
73 |
+ |
/** |
|
74 |
+ |
* Gets the button value. |
|
75 |
+ |
* |
|
76 |
+ |
* @return gets the button value. |
|
77 |
+ |
*/ |
|
78 |
+ |
public Button getButton() { |
|
79 |
+ |
return Button.valueOf( getNativeEvent().getButton() ); |
|
80 |
+ |
} |
|
81 |
+ |
|
|
82 |
+ |
/** |
|
83 |
+ |
* Gets the mouse x-position within the browser window's client area. |
|
84 |
+ |
* |
|
85 |
+ |
* @return the mouse x-position |
|
86 |
+ |
*/ |
|
87 |
+ |
public int getClientX() { |
|
88 |
+ |
return getNativeEvent().getClientX(); |
|
89 |
+ |
} |
|
90 |
+ |
|
|
91 |
+ |
/** |
|
92 |
+ |
* Gets the mouse y-position within the browser window's client area. |
|
93 |
+ |
* |
|
94 |
+ |
* @return the mouse y-position |
|
95 |
+ |
*/ |
|
96 |
+ |
public int getClientY() { |
|
97 |
+ |
return getNativeEvent().getClientY(); |
|
98 |
+ |
} |
|
99 |
+ |
|
|
100 |
+ |
/** |
|
101 |
+ |
* Gets the mouse x-position on the user's display. |
|
102 |
+ |
* |
|
103 |
+ |
* @return the mouse x-position |
|
104 |
+ |
*/ |
|
105 |
+ |
public int getScreenX() { |
|
106 |
+ |
return getNativeEvent().getScreenX(); |
|
107 |
+ |
} |
|
108 |
+ |
|
|
109 |
+ |
/** |
|
110 |
+ |
* Gets the mouse y-position on the user's display. |
|
111 |
+ |
* |
|
112 |
+ |
* @return the mouse y-position |
|
113 |
+ |
*/ |
|
114 |
+ |
public int getScreenY() { |
|
115 |
+ |
return getNativeEvent().getScreenY(); |
|
116 |
+ |
} |
|
117 |
+ |
|
|
118 |
+ |
/** |
|
119 |
+ |
* Is <code>alt</code> key down. |
|
120 |
+ |
* |
|
121 |
+ |
* @return whether the alt key is down |
|
122 |
+ |
*/ |
|
123 |
+ |
public boolean isAltKeyDown() { |
|
124 |
+ |
return getNativeEvent().getAltKey(); |
|
125 |
+ |
} |
|
126 |
+ |
|
|
127 |
+ |
/** |
|
128 |
+ |
* Is <code>control</code> key down. |
|
129 |
+ |
* |
|
130 |
+ |
* @return whether the control key is down |
|
131 |
+ |
*/ |
|
132 |
+ |
public boolean isControlKeyDown() { |
|
133 |
+ |
return getNativeEvent().getCtrlKey(); |
|
134 |
+ |
} |
|
135 |
+ |
|
|
136 |
+ |
/** |
|
137 |
+ |
* Is <code>meta</code> key down. |
|
138 |
+ |
* |
|
139 |
+ |
* @return whether the meta key is down |
|
140 |
+ |
*/ |
|
141 |
+ |
public boolean isMetaKeyDown() { |
|
142 |
+ |
return getNativeEvent().getMetaKey(); |
|
143 |
+ |
} |
|
144 |
+ |
|
|
145 |
+ |
/** |
|
146 |
+ |
* Is <code>shift</code> key down. |
|
147 |
+ |
* |
|
148 |
+ |
* @return whether the shift key is down |
|
149 |
+ |
*/ |
|
150 |
+ |
public boolean isShiftKeyDown() { |
|
151 |
+ |
return getNativeEvent().getShiftKey(); |
|
152 |
+ |
} |
|
153 |
+ |
} |