001    /*
002     * Copyright 2006 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       * A bit-mask covering both focus events.
047       */
048      public static final int FOCUSEVENTS = 0x01800;
049    
050      /**
051       * A bit-mask covering all keyboard events.
052       */
053      public static final int KEYEVENTS = 0x00380;
054    
055      /**
056       * A bit-mask covering all mouse events.
057       */
058      public static final int MOUSEEVENTS = 0x0007C;
059    
060      /**
061       * Fired when an element loses keyboard focus.
062       */
063      public static final int ONBLUR = 0x01000;
064    
065      /**
066       * Fired when the value of an input element changes.
067       */
068      public static final int ONCHANGE = 0x00400;
069    
070      /**
071       * Fired when the user clicks on an element.
072       */
073      public static final int ONCLICK = 0x00001;
074    
075      /**
076       * Fired when the user double-clicks on an element.
077       */
078      public static final int ONDBLCLICK = 0x00002;
079    
080      /**
081       * Fired when a scrollable element's scroll offset changes.
082       */
083      public static final int ONERROR = 0x10000;
084    
085      /**
086       * Fired when an element receives keyboard focus.
087       */
088      public static final int ONFOCUS = 0x00800;
089    
090      /**
091       * Fired when the user depresses a key.
092       */
093      public static final int ONKEYDOWN = 0x00080;
094    
095      /**
096       * Fired when the a character is generated from a keypress (either directly or
097       * through auto-repeat).
098       */
099      public static final int ONKEYPRESS = 0x00100;
100    
101      /**
102       * Fired when the user releases a key.
103       */
104      public static final int ONKEYUP = 0x00200;
105    
106      /**
107       * Fired when an element (normally an IMG) finishes loading.
108       */
109      public static final int ONLOAD = 0x08000;
110    
111      /**
112       * Fired when an element that has mouse capture loses it.
113       */
114      public static final int ONLOSECAPTURE = 0x02000;
115    
116      /**
117       * Fired when the user depresses a mouse button over an element.
118       */
119      public static final int ONMOUSEDOWN = 0x00004;
120    
121      /**
122       * Fired when the mouse is moved within an element's area.
123       */
124      public static final int ONMOUSEMOVE = 0x00040;
125    
126      /**
127       * Fired when the mouse is moved out of an element's area.
128       */
129      public static final int ONMOUSEOUT = 0x00020;
130    
131      /**
132       * Fired when the mouse is moved into an element's area.
133       */
134      public static final int ONMOUSEOVER = 0x00010;
135    
136      /**
137       * Fired when the user releases a mouse button over an element.
138       */
139      public static final int ONMOUSEUP = 0x00008;
140    
141      /**
142       * Fired when a scrollable element's scroll offset changes.
143       */
144      public static final int ONSCROLL = 0x04000;
145    
146      /**
147       * Creates a new <code>Element</code>. This constructor is used internally
148       * and should never be called by a user.
149       * 
150       * @param opaque the underlying DOM element
151       */
152      Event(int opaque) {
153        super(opaque);
154      }
155    
156      /*
157       * (non-Javadoc)
158       * 
159       * @see java.lang.Object#equals(java.lang.Object)
160       */
161      public boolean equals(Object other) {
162        return super.equals(other);
163      }
164    
165      /*
166       * (non-Javadoc)
167       * 
168       * @see java.lang.Object#hashCode()
169       */
170      public int hashCode() {
171        return super.hashCode();
172      }
173    
174      /*
175       * (non-Javadoc)
176       * 
177       * @see java.lang.Object#toString()
178       */
179      public String toString() {
180        return DOM.eventToString(this);
181      };
182    }