KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > user > client > Event


1 /*
2  * Copyright 2007 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.user.client;
17
18 import com.google.gwt.core.client.JavaScriptObject;
19
20 /**
21  * An opaque handle to a native DOM Event. An <code>Event</code> cannot be
22  * created directly. Instead, use the <code>Event</code> type when returning a
23  * native DOM event from JSNI methods. An <code>Event</code> passed back into
24  * JSNI becomes the original DOM event the <code>Event</code> was created
25  * from, and can be accessed in JavaScript code as expected. This is typically
26  * done by calling methods in the {@link com.google.gwt.user.client.DOM} class.
27  */

28 public final class Event extends JavaScriptObject {
29
30   /**
31    * The left mouse button (used in {@link DOM#eventGetButton(Event)}).
32    */

33   public static final int BUTTON_LEFT = 1;
34
35   /**
36    * The middle mouse button (used in {@link DOM#eventGetButton(Event)}).
37    */

38   public static final int BUTTON_MIDDLE = 4;
39
40   /**
41    * The right mouse button (used in {@link DOM#eventGetButton(Event)}).
42    */

43   public static final int BUTTON_RIGHT = 2;
44
45   /**
46    * Fired when an element loses keyboard focus.
47    */

48   public static final int ONBLUR = 0x01000;
49
50   /**
51    * Fired when the value of an input element changes.
52    */

53   public static final int ONCHANGE = 0x00400;
54
55   /**
56    * Fired when the user clicks on an element.
57    */

58   public static final int ONCLICK = 0x00001;
59
60   /**
61    * Fired when the user double-clicks on an element.
62    */

63   public static final int ONDBLCLICK = 0x00002;
64
65   /**
66    * Fired when an image encounters an error.
67    */

68   public static final int ONERROR = 0x10000;
69
70   /**
71    * Fired when an element receives keyboard focus.
72    */

73   public static final int ONFOCUS = 0x00800;
74
75   /**
76    * Fired when the user depresses a key.
77    */

78   public static final int ONKEYDOWN = 0x00080;
79
80   /**
81    * Fired when the a character is generated from a keypress (either directly or
82    * through auto-repeat).
83    */

84   public static final int ONKEYPRESS = 0x00100;
85
86   /**
87    * Fired when the user releases a key.
88    */

89   public static final int ONKEYUP = 0x00200;
90
91   /**
92    * Fired when an element (normally an IMG) finishes loading.
93    */

94   public static final int ONLOAD = 0x08000;
95
96   /**
97    * Fired when an element that has mouse capture loses it.
98    */

99   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 | ONKEYUP;
145
146   /**
147    * A bit-mask covering all mouse events (down, up, move, over, and out), but
148    * not click, dblclick, or wheel events.
149    */

150   public static final int MOUSEEVENTS = ONMOUSEDOWN | ONMOUSEUP | ONMOUSEMOVE
151     | ONMOUSEOVER | ONMOUSEOUT;
152
153   /**
154    * Not directly instantiable. Subclasses should also define a protected
155    * no-arg constructor to prevent client code from directly instantiating
156    * the class.
157    */

158   protected Event() {
159   }
160
161   /*
162    * (non-Javadoc)
163    *
164    * @see java.lang.Object#equals(java.lang.Object)
165    */

166   public boolean equals(Object JavaDoc other) {
167     return super.equals(other);
168   }
169
170   /*
171    * (non-Javadoc)
172    *
173    * @see java.lang.Object#hashCode()
174    */

175   public int hashCode() {
176     return super.hashCode();
177   }
178
179   /*
180    * (non-Javadoc)
181    *
182    * @see java.lang.Object#toString()
183    */

184   public String JavaDoc toString() {
185     return DOM.eventToString(this);
186   };
187 }
188
Popular Tags