001: /*
002: * Copyright 2007 Google Inc.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License. You may obtain a copy of
006: * the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013: * License for the specific language governing permissions and limitations under
014: * the License.
015: */
016: package com.google.gwt.user.client;
017:
018: import com.google.gwt.core.client.JavaScriptObject;
019:
020: /**
021: * An opaque handle to a native DOM Event. An <code>Event</code> cannot be
022: * created directly. Instead, use the <code>Event</code> type when returning a
023: * native DOM event from JSNI methods. An <code>Event</code> passed back into
024: * JSNI becomes the original DOM event the <code>Event</code> was created
025: * from, and can be accessed in JavaScript code as expected. This is typically
026: * done by calling methods in the {@link com.google.gwt.user.client.DOM} class.
027: */
028: public final class Event extends JavaScriptObject {
029:
030: /**
031: * The left mouse button (used in {@link DOM#eventGetButton(Event)}).
032: */
033: public static final int BUTTON_LEFT = 1;
034:
035: /**
036: * The middle mouse button (used in {@link DOM#eventGetButton(Event)}).
037: */
038: public static final int BUTTON_MIDDLE = 4;
039:
040: /**
041: * The right mouse button (used in {@link DOM#eventGetButton(Event)}).
042: */
043: public static final int BUTTON_RIGHT = 2;
044:
045: /**
046: * Fired when an element loses keyboard focus.
047: */
048: public static final int ONBLUR = 0x01000;
049:
050: /**
051: * Fired when the value of an input element changes.
052: */
053: public static final int ONCHANGE = 0x00400;
054:
055: /**
056: * Fired when the user clicks on an element.
057: */
058: public static final int ONCLICK = 0x00001;
059:
060: /**
061: * Fired when the user double-clicks on an element.
062: */
063: public static final int ONDBLCLICK = 0x00002;
064:
065: /**
066: * Fired when an image encounters an error.
067: */
068: public static final int ONERROR = 0x10000;
069:
070: /**
071: * Fired when an element receives keyboard focus.
072: */
073: public static final int ONFOCUS = 0x00800;
074:
075: /**
076: * Fired when the user depresses a key.
077: */
078: public static final int ONKEYDOWN = 0x00080;
079:
080: /**
081: * Fired when the a character is generated from a keypress (either directly or
082: * through auto-repeat).
083: */
084: public static final int ONKEYPRESS = 0x00100;
085:
086: /**
087: * Fired when the user releases a key.
088: */
089: public static final int ONKEYUP = 0x00200;
090:
091: /**
092: * Fired when an element (normally an IMG) finishes loading.
093: */
094: public static final int ONLOAD = 0x08000;
095:
096: /**
097: * Fired when an element that has mouse capture loses it.
098: */
099: public static final int ONLOSECAPTURE = 0x02000;
100:
101: /**
102: * Fired when the user depresses a mouse button over an element.
103: */
104: public static final int ONMOUSEDOWN = 0x00004;
105:
106: /**
107: * Fired when the mouse is moved within an element's area.
108: */
109: public static final int ONMOUSEMOVE = 0x00040;
110:
111: /**
112: * Fired when the mouse is moved out of an element's area.
113: */
114: public static final int ONMOUSEOUT = 0x00020;
115:
116: /**
117: * Fired when the mouse is moved into an element's area.
118: */
119: public static final int ONMOUSEOVER = 0x00010;
120:
121: /**
122: * Fired when the user releases a mouse button over an element.
123: */
124: public static final int ONMOUSEUP = 0x00008;
125:
126: /**
127: * Fired when the user scrolls the mouse wheel over an element.
128: */
129: public static final int ONMOUSEWHEEL = 0x20000;
130:
131: /**
132: * Fired when a scrollable element's scroll offset changes.
133: */
134: public static final int ONSCROLL = 0x04000;
135:
136: /**
137: * A bit-mask covering both focus events (focus and blur).
138: */
139: public static final int FOCUSEVENTS = ONFOCUS | ONBLUR;
140:
141: /**
142: * A bit-mask covering all keyboard events (down, up, and press).
143: */
144: public static final int KEYEVENTS = ONKEYDOWN | ONKEYPRESS
145: | ONKEYUP;
146:
147: /**
148: * A bit-mask covering all mouse events (down, up, move, over, and out), but
149: * not click, dblclick, or wheel events.
150: */
151: public static final int MOUSEEVENTS = ONMOUSEDOWN | ONMOUSEUP
152: | ONMOUSEMOVE | ONMOUSEOVER | ONMOUSEOUT;
153:
154: /**
155: * Error code returned by DOM.getEventXXX methods when the actual integer
156: * value is undefined. For example, DOM.getEventKeyCode returns UNDEFINED
157: * for some non-keyboard events.
158: *
159: * For some events, some browsers return undefined while others return data
160: * for certain events.
161: */
162: public static final int UNDEFINED = -1;
163:
164: /**
165: * Not directly instantiable. Subclasses should also define a protected
166: * no-arg constructor to prevent client code from directly instantiating
167: * the class.
168: */
169: protected Event() {
170: }
171:
172: /*
173: * (non-Javadoc)
174: *
175: * @see java.lang.Object#equals(java.lang.Object)
176: */
177: @Override
178: public boolean equals(Object other) {
179: return super .equals(other);
180: }
181:
182: /*
183: * (non-Javadoc)
184: *
185: * @see java.lang.Object#hashCode()
186: */
187: @Override
188: public int hashCode() {
189: return super .hashCode();
190: }
191:
192: /*
193: * (non-Javadoc)
194: *
195: * @see java.lang.Object#toString()
196: */
197: @Override
198: public String toString() {
199: return DOM.eventToString(this);
200: }
201: }
|