Package com.google.gwt.dom.client
Class NativeEvent
java.lang.Object
com.google.gwt.core.client.JavaScriptObject
com.google.gwt.dom.client.NativeEvent
- Direct Known Subclasses:
Event
The native dom event.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The left mouse button.static final int
The middle mouse button.static final int
The right mouse button. -
Constructor Summary
ModifierConstructorDescriptionprotected
Required constructor for GWT compiler to function. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Gets whether the ALT key was depressed when the given event occurred.final int
Gets the mouse buttons that were depressed when the given event occurred.Get an array of touches which have changed since the last touch event.final int
Gets the Unicode codepoint of the character generated by this key event.final int
Gets the mouse x-position within the browser window's client area.final int
Gets the mouse y-position within the browser window's client area.final boolean
Gets whether the CTRL key was depressed when the given event occurred.final EventTarget
Gets the current target element of this event.final DataTransfer
Get theDataTransfer
associated with the current drag event.final double
Gets the native velocity of the mouse wheel in X direction.final double
Gets the native velocity of the mouse wheel in Y direction.final EventTarget
Returns the element that was the actual target of the given event.final int
Gets the key code (code associated with the physical key) associated with this event.final boolean
Gets whether the META key was depressed when the given event occurred.final int
Deprecated.use getDeltaY() insteadfinal EventTarget
Gets the related target for this event.final double
Get the rotation in degrees, with positive values indicating clockwise rotation.final double
getScale()
Get the amount scaled since the gesture started, with 1.0 representing no scaling.final int
Gets the mouse x-position on the user's display.final int
Gets the mouse y-position on the user's display.final boolean
Gets whether the shift key was depressed when the given event occurred.final String
Gets a string representation of this event.Get an array of touches which have changed since the last touch event.Get an array of touches which have changed since the last touch event.final String
getType()
Gets the enumerated type of this event.final void
Prevents the browser from taking its default action for the given event.final void
Stops the event from being propagated to parent elements.Methods inherited from class com.google.gwt.core.client.JavaScriptObject
cast, createArray, createArray, createFunction, createObject, equals, hashCode, toSource, toString
-
Field Details
-
BUTTON_LEFT
public static final int BUTTON_LEFTThe left mouse button.- See Also:
-
BUTTON_MIDDLE
public static final int BUTTON_MIDDLEThe middle mouse button.- See Also:
-
BUTTON_RIGHT
public static final int BUTTON_RIGHTThe right mouse button.- See Also:
-
-
Constructor Details
-
NativeEvent
protected NativeEvent()Required constructor for GWT compiler to function.
-
-
Method Details
-
getAltKey
public final boolean getAltKey()Gets whether the ALT key was depressed when the given event occurred.- Returns:
true
if ALT was depressed when the event occurred
-
getButton
public final int getButton()Gets the mouse buttons that were depressed when the given event occurred.- Returns:
- a bit-field, defined by
BUTTON_LEFT
,BUTTON_MIDDLE
, andBUTTON_RIGHT
-
getChangedTouches
Get an array of touches which have changed since the last touch event.- Returns:
- array of touches which have changed since the last touch event
-
getCharCode
public final int getCharCode()Gets the Unicode codepoint of the character generated by this key event.- Returns:
- the Unicode codepoint.
-
getClientX
public final int getClientX()Gets the mouse x-position within the browser window's client area.- Returns:
- the mouse x-position
-
getClientY
public final int getClientY()Gets the mouse y-position within the browser window's client area.- Returns:
- the mouse y-position
-
getCtrlKey
public final boolean getCtrlKey()Gets whether the CTRL key was depressed when the given event occurred.- Returns:
true
if CTRL was depressed when the event occurred
-
getCurrentEventTarget
Gets the current target element of this event. This is the element whose listener fired last, not the element which fired the event initially.- Returns:
- the event's current target element
-
getDataTransfer
Get theDataTransfer
associated with the current drag event.- Returns:
- the
DataTransfer
object, or null if not a drag event
-
getEventTarget
Returns the element that was the actual target of the given event.- Returns:
- the target element
-
getKeyCode
public final int getKeyCode()Gets the key code (code associated with the physical key) associated with this event.- Returns:
- the key code
- See Also:
-
getMetaKey
public final boolean getMetaKey()Gets whether the META key was depressed when the given event occurred.- Returns:
true
if META was depressed when the event occurred
-
getMouseWheelVelocityY
Deprecated.use getDeltaY() insteadGets the sign of the velocity of the mouse wheel associated with the event along the Y axis.In previous versions of GWT this returned the velocity normalized to a small integer. Unfortunately for some devices such normalization rounded non-trivial velocities to 0. To maintain compatibility with that implementation, this still returns an integer, but using the sign function
- Returns:
- The velocity of the mouse wheel: -1 for scrolling up, 1 for scrolling down, 0 if not scrolled at all
-
getDeltaY
public final double getDeltaY()Gets the native velocity of the mouse wheel in Y direction.- Returns:
- The velocity of the mouse wheel
-
getDeltaX
public final double getDeltaX()Gets the native velocity of the mouse wheel in X direction.- Returns:
- The velocity of the mouse wheel
-
getRelatedEventTarget
Gets the related target for this event.- Returns:
- the related target
-
getRotation
public final double getRotation()Get the rotation in degrees, with positive values indicating clockwise rotation.- Returns:
- the rotation in degrees since the gesture started
-
getScale
public final double getScale()Get the amount scaled since the gesture started, with 1.0 representing no scaling.- Returns:
- the amount scaled since the gesture started
-
getScreenX
public final int getScreenX()Gets the mouse x-position on the user's display.- Returns:
- the mouse x-position
-
getScreenY
public final int getScreenY()Gets the mouse y-position on the user's display.- Returns:
- the mouse y-position
-
getShiftKey
public final boolean getShiftKey()Gets whether the shift key was depressed when the given event occurred.- Returns:
true
if shift was depressed when the event occurred
-
getString
Gets a string representation of this event. We do not overrideJavaScriptObject.toString()
because it is final inJavaScriptObject
.- Returns:
- the string representation of this event
-
getTargetTouches
Get an array of touches which have changed since the last touch event.- Returns:
- array of touches which have changed since the last touch event
-
getTouches
Get an array of touches which have changed since the last touch event.- Returns:
- array of touches which have changed since the last touch event
-
getType
Gets the enumerated type of this event.- Returns:
- the event's enumerated type
-
preventDefault
public final void preventDefault()Prevents the browser from taking its default action for the given event. -
stopPropagation
public final void stopPropagation()Stops the event from being propagated to parent elements.
-