|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.gwt.core.client.JavaScriptObject
com.google.gwt.user.client.Event
public class Event
An opaque handle to a native DOM Event. An Event
cannot be
created directly. Instead, use the Event
type when returning a
native DOM event from JSNI methods. An Event
passed back into
JSNI becomes the original DOM event the Event
was created
from, and can be accessed in JavaScript code as expected. This is typically
done by calling methods in the DOM
class.
In hosted mode, most accessors (eg. EventgetKeyCode()
and
getButton()
) assert that the requested attribute is reliable
across all supported browsers. This means that attempting to retrieve an
attribute for an Event
that does not support that attribute will
throw an AssertionError
. For example, an Event
of type
ONCLICK
will throw an AssertionError
if you attempt
to get the mouse button that was clicked using getButton()
because the mouse button attribute is not defined for ONCLICK
on Internet Explorer.
Field Summary | |
---|---|
static int |
BUTTON_LEFT
The left mouse button (used in DOM.eventGetButton(Event) ). |
static int |
BUTTON_MIDDLE
The middle mouse button (used in DOM.eventGetButton(Event) ). |
static int |
BUTTON_RIGHT
The right mouse button (used in DOM.eventGetButton(Event) ). |
static int |
FOCUSEVENTS
A bit-mask covering both focus events (focus and blur). |
static int |
KEYEVENTS
A bit-mask covering all keyboard events (down, up, and press). |
static int |
MOUSEEVENTS
A bit-mask covering all mouse events (down, up, move, over, and out), but not click, dblclick, or wheel events. |
static int |
ONBLUR
Fired when an element loses keyboard focus. |
static int |
ONCHANGE
Fired when the value of an input element changes. |
static int |
ONCLICK
Fired when the user clicks on an element. |
static int |
ONCONTEXTMENU
Fired when the user requests an element's context menu (usually by right-clicking). |
static int |
ONDBLCLICK
Fired when the user double-clicks on an element. |
static int |
ONERROR
Fired when an image encounters an error. |
static int |
ONFOCUS
Fired when an element receives keyboard focus. |
static int |
ONKEYDOWN
Fired when the user depresses a key. |
static int |
ONKEYPRESS
Fired when the a character is generated from a keypress (either directly or through auto-repeat). |
static int |
ONKEYUP
Fired when the user releases a key. |
static int |
ONLOAD
Fired when an element (normally an IMG) finishes loading. |
static int |
ONLOSECAPTURE
Fired when an element that has mouse capture loses it. |
static int |
ONMOUSEDOWN
Fired when the user depresses a mouse button over an element. |
static int |
ONMOUSEMOVE
Fired when the mouse is moved within an element's area. |
static int |
ONMOUSEOUT
Fired when the mouse is moved out of an element's area. |
static int |
ONMOUSEOVER
Fired when the mouse is moved into an element's area. |
static int |
ONMOUSEUP
Fired when the user releases a mouse button over an element. |
static int |
ONMOUSEWHEEL
Fired when the user scrolls the mouse wheel over an element. |
static int |
ONSCROLL
Fired when a scrollable element's scroll offset changes. |
static int |
UNDEFINED
Deprecated. |
Constructor Summary | |
---|---|
protected |
Event()
Not directly instantiable. |
Method Summary | |
---|---|
static void |
addEventPreview(EventPreview preview)
Adds an event preview to the preview stack. |
void |
cancelBubble(boolean cancel)
Cancels bubbling for the given event. |
boolean |
getAltKey()
Gets whether the ALT key was depressed when the given event occurred. |
int |
getButton()
Gets the mouse buttons that were depressed when the given event occurred. |
int |
getClientX()
Gets the mouse x-position within the browser window's client area. |
int |
getClientY()
Gets the mouse y-position within the browser window's client area. |
boolean |
getCtrlKey()
Gets whether the CTRL key was depressed when the given event occurred. |
static Event |
getCurrentEvent()
Gets the current event that is being fired. |
Element |
getCurrentTarget()
Gets the current target element of this event. |
static int |
getEventsSunk(Element elem)
Gets the current set of events sunk by a given element. |
Element |
getFromElement()
Gets the element from which the mouse pointer was moved (only valid for ONMOUSEOVER ). |
int |
getKeyCode()
Gets the key code associated with this event. |
boolean |
getMetaKey()
Gets whether the META key was depressed when the given event occurred. |
int |
getMouseWheelVelocityY()
Gets the velocity of the mouse wheel associated with the event along the Y axis. |
boolean |
getRepeat()
Gets the key-repeat state of this event. |
int |
getScreenX()
Gets the mouse x-position on the user's display. |
int |
getScreenY()
Gets the mouse y-position on the user's display. |
boolean |
getShiftKey()
Gets whether the shift key was depressed when the given event occurred. |
java.lang.String |
getString()
Gets a string representation of this event. |
Element |
getTarget()
Returns the element that was the actual target of the given event. |
Element |
getToElement()
Gets the element to which the mouse pointer was moved (only valid for ONMOUSEOUT ). |
java.lang.String |
getType()
Gets the enumerated type of this event (as defined in Event ). |
int |
getTypeInt()
Gets the enumerated type of this event, as defined by ONCLICK ,
ONMOUSEDOWN , and so forth. |
void |
preventDefault()
Prevents the browser from taking its default action for the given event. |
static void |
releaseCapture(Element elem)
Releases mouse capture on the given element. |
static void |
removeEventPreview(EventPreview preview)
Removes an element from the preview stack. |
static void |
setCapture(Element elem)
Sets mouse-capture on the given element. |
static void |
sinkEvents(Element elem,
int eventBits)
Sets the current set of events sunk by a given element. |
Methods inherited from class com.google.gwt.core.client.JavaScriptObject |
---|
cast, createArray, createFunction, createObject, equals, hashCode, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int BUTTON_LEFT
DOM.eventGetButton(Event)
).
public static final int BUTTON_MIDDLE
DOM.eventGetButton(Event)
).
public static final int BUTTON_RIGHT
DOM.eventGetButton(Event)
).
public static final int ONBLUR
public static final int ONCHANGE
public static final int ONCLICK
public static final int ONDBLCLICK
public static final int ONERROR
public static final int ONFOCUS
public static final int ONKEYDOWN
public static final int ONKEYPRESS
public static final int ONKEYUP
public static final int ONLOAD
public static final int ONLOSECAPTURE
public static final int ONMOUSEDOWN
public static final int ONMOUSEMOVE
public static final int ONMOUSEOUT
public static final int ONMOUSEOVER
public static final int ONMOUSEUP
public static final int ONMOUSEWHEEL
public static final int ONSCROLL
public static final int ONCONTEXTMENU
public static final int FOCUSEVENTS
public static final int KEYEVENTS
public static final int MOUSEEVENTS
@Deprecated public static final int UNDEFINED
Event
,
Constant Field ValuesConstructor Detail |
---|
protected Event()
Method Detail |
---|
public static void addEventPreview(EventPreview preview)
preview
- the event preview to be added to the stack.public static Event getCurrentEvent()
public static int getEventsSunk(Element elem)
elem
- the element whose events are to be retrieved
Event
)public static void releaseCapture(Element elem)
elem
- the element to release capturesetCapture(Element)
public static void removeEventPreview(EventPreview preview)
preview
- the event preview to be removed from the stackpublic static void setCapture(Element elem)
releaseCapture(Element)
is called on it.
elem
- the element on which to set mouse capturepublic static void sinkEvents(Element elem, int eventBits)
EventListener
specified on any of the
element's parents.
elem
- the element whose events are to be retrievedeventBits
- a bitfield describing the events sunk on this element (its
possible values are described in Event
)public final void cancelBubble(boolean cancel)
cancel
- true
to cancel bubblingpublic final boolean getAltKey() throws java.lang.AssertionError
true
if ALT was depressed when the event occurred
java.lang.AssertionError
- if event type is not one of
MOUSEEVENTS
, ONCLICK
,
ONDBLCLICK
, KEYEVENTS
, or
ONCONTEXTMENU
public final int getButton() throws java.lang.AssertionError
BUTTON_LEFT
,
BUTTON_MIDDLE
, and BUTTON_RIGHT
java.lang.AssertionError
- if event type is not one of
ONMOUSEDOWN
or ONMOUSEUP
public final int getClientX() throws java.lang.AssertionError
java.lang.AssertionError
- if event type is not one of
MOUSEEVENTS
, ONCLICK
,
ONDBLCLICK
, ONMOUSEWHEEL
, or
ONCONTEXTMENU
public final int getClientY() throws java.lang.AssertionError
java.lang.AssertionError
- if event type is not one of
MOUSEEVENTS
, ONCLICK
,
ONDBLCLICK
, ONMOUSEWHEEL
, or
ONCONTEXTMENU
public final boolean getCtrlKey() throws java.lang.AssertionError
true
if CTRL was depressed when the event occurred
java.lang.AssertionError
- if event type is not one of
MOUSEEVENTS
, ONCLICK
,
ONDBLCLICK
, KEYEVENTS
, or
ONCONTEXTMENU
public final Element getCurrentTarget()
public final Element getFromElement() throws java.lang.AssertionError
ONMOUSEOVER
).
java.lang.AssertionError
- if event type is not one of
ONMOUSEOVER
or ONMOUSEOUT
public final int getKeyCode() throws java.lang.AssertionError
For ONKEYPRESS
, this method returns the Unicode value of the
character generated. For ONKEYDOWN
and ONKEYUP
,
it returns the code associated with the physical key.
java.lang.AssertionError
- if event type is not one of KEYEVENTS
KeyboardListener
public final boolean getMetaKey() throws java.lang.AssertionError
true
if META was depressed when the event occurred
java.lang.AssertionError
- if event type is not one of
MOUSEEVENTS
, ONCLICK
,
ONDBLCLICK
, KEYEVENTS
, or
ONCONTEXTMENU
public final int getMouseWheelVelocityY() throws java.lang.AssertionError
The velocity of the event is an artifical measurement for relative comparisons of wheel activity. It is affected by some non-browser factors, including choice of input hardware and mouse acceleration settings. The sign of the velocity measurement agrees with the screen coordinate system; negative values are towards the origin and positive values are away from the origin. Standard scrolling speed is approximately ten units per event.
java.lang.AssertionError
- if event type is not ONMOUSEWHEEL
public final boolean getRepeat() throws java.lang.AssertionError
true
if this key event was an auto-repeat
java.lang.AssertionError
- if event type is not ONKEYDOWN
public final int getScreenX() throws java.lang.AssertionError
java.lang.AssertionError
- if event type is not one of
MOUSEEVENTS
, ONMOUSEWHEEL
,
ONCLICK
, ONDBLCLICK
, or
ONCONTEXTMENU
public final int getScreenY() throws java.lang.AssertionError
java.lang.AssertionError
- if event type is not one of
MOUSEEVENTS
, ONMOUSEWHEEL
,
ONCLICK
, ONDBLCLICK
, or
ONCONTEXTMENU
public final boolean getShiftKey() throws java.lang.AssertionError
true
if shift was depressed when the event occurred
java.lang.AssertionError
- if event type is not one of
MOUSEEVENTS
, ONCLICK
,
ONDBLCLICK
, KEYEVENTS
, or
ONCONTEXTMENU
public final java.lang.String getString()
JavaScriptObject.toString()
because it is final in
JavaScriptObject
.
public final Element getTarget()
public final Element getToElement() throws java.lang.AssertionError
ONMOUSEOUT
).
java.lang.AssertionError
- if event type is not one of
ONMOUSEOVER
or ONMOUSEOUT
public final java.lang.String getType()
Event
).
public final int getTypeInt()
ONCLICK
,
ONMOUSEDOWN
, and so forth.
public final void preventDefault()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |