public class Event extends SimpleScriptable
Modifier and Type | Field and Description |
---|---|
static int |
ALT_MASK
Constant.
|
static short |
AT_TARGET
The second event phase: at the event target.
|
static int |
BLUR
Constant.
|
static short |
BUBBLING_PHASE
The third (and final) event phase: the bubbling phase.
|
static short |
CAPTURING_PHASE
The first event phase: the capturing phase.
|
static int |
CHANGE
Constant.
|
static int |
CLICK
Constant.
|
static int |
CONTROL_MASK
Constant.
|
static int |
DBLCLICK
Constant.
|
static int |
DRAGDROP
Constant.
|
static int |
FOCUS
Constant.
|
protected static String |
KEY_CURRENT_EVENT
Key to place the event's target in the Context's scope during event processing
to compute node coordinates compatible with those of the event.
|
static int |
KEYDOWN
Constant.
|
static int |
KEYPRESS
Constant.
|
static int |
KEYUP
Constant.
|
static int |
META_MASK
Constant.
|
static int |
MOUSEDOWN
Constant.
|
static int |
MOUSEDRAG
Constant.
|
static int |
MOUSEMOVE
Constant.
|
static int |
MOUSEOUT
Constant.
|
static int |
MOUSEOVER
Constant.
|
static int |
MOUSEUP
Constant.
|
static short |
NONE
No event phase.
|
static int |
SELECT
Constant.
|
static int |
SHIFT_MASK
Constant.
|
static String |
TYPE_BEFORE_UNLOAD
The beforeunload event type, triggered by
onbeforeunload event handlers. |
static String |
TYPE_BLUR
The blur event type, triggered by
onblur event handlers. |
static String |
TYPE_CHANGE
The change event type, triggered by
onchange event handlers. |
static String |
TYPE_CLOSE
The close event type, triggered by
onclose event handlers. |
static String |
TYPE_DOM_DOCUMENT_LOADED
Triggered after the DOM has loaded but before images etc.
|
static String |
TYPE_ERROR
The event type triggered by
onerror event handlers. |
static String |
TYPE_FOCUS
The focus event type, triggered by
onfocus event handlers. |
static String |
TYPE_FOCUS_IN
The focus in event type, triggered by
onfocusin event handlers. |
static String |
TYPE_FOCUS_OUT
The focus out event type, triggered by
onfocusout event handlers. |
static String |
TYPE_HASH_CHANGE
The event type triggered by
onhashchange event handlers. |
static String |
TYPE_INPUT
The input event type, triggered by
oninput event handlers. |
static String |
TYPE_KEY_DOWN
The key down event type, triggered by
onkeydown event handlers. |
static String |
TYPE_KEY_PRESS
The key down event type, triggered by
onkeypress event handlers. |
static String |
TYPE_KEY_UP
The key down event type, triggered by
onkeyup event handlers. |
static String |
TYPE_LOAD
The load event type, triggered by
onload event handlers. |
static String |
TYPE_MESSAGE
The message event type, triggered by postMessage.
|
static String |
TYPE_OPEN
The open event type, triggered by
onopen event handlers. |
static String |
TYPE_POPSTATE
The popstate event type, triggered by
onpopstate event handlers. |
static String |
TYPE_PROPERTY_CHANGE
The event type triggered by
onpropertychange event handlers. |
static String |
TYPE_READY_STATE_CHANGE
The event type triggered by
onreadystatechange event handlers. |
static String |
TYPE_RESET
The submit event type, triggered by
onreset event handlers. |
static String |
TYPE_SUBMIT
The submit event type, triggered by
onsubmit event handlers. |
static String |
TYPE_UNLOAD
The unload event type, triggered by
onunload event handlers. |
Constructor and Description |
---|
Event()
Used to build the prototype.
|
Event(DomNode domNode,
String type)
Creates a new event instance.
|
Event(SimpleScriptable scriptable,
String type)
Creates a new event instance.
|
Modifier and Type | Method and Description |
---|---|
static Event |
createPropertyChangeEvent(DomNode domNode,
String propertyName)
Creates a new Event with
TYPE_PROPERTY_CHANGE type. |
void |
endFire()
Called when the event being fired ends.
|
void |
eventCreated()
Called whenever an event is created using
Document.createEvent(..) . |
boolean |
getAltKey()
Returns whether
ALT has been pressed during this event or not. |
boolean |
getBubbles() |
boolean |
getCancelable() |
boolean |
getCancelBubble() |
boolean |
getCtrlKey()
Returns whether
CTRL has been pressed during this event or not. |
net.sourceforge.htmlunit.corejs.javascript.Scriptable |
getCurrentTarget()
Returns the event target whose event listeners are currently being processed.
|
boolean |
getDefaultPrevented()
Returns
true if both cancelable is true and preventDefault() has been
called for this event. |
int |
getEventPhase()
Returns the current event phase for the event.
|
Object |
getKeyCode()
Returns the key code associated with the event.
|
String |
getPropertyName()
Returns the property name associated with the event.
|
Object |
getReturnValue()
Returns the return value associated with the event.
|
boolean |
getShiftKey()
Returns whether
SHIFT has been pressed during this event or not. |
Object |
getSrcElement()
Returns the object that fired the event.
|
Object |
getTarget()
Returns the event target to which the event was originally dispatched.
|
long |
getTimeStamp()
Returns the time at which this event was created.
|
String |
getType()
Returns the event type.
|
void |
initEvent(String type,
boolean bubbles,
boolean cancelable)
Initializes this event.
|
boolean |
isAborted(ScriptResult result)
Returns
true if this event has been aborted via preventDefault() in
standards-compliant browsers, or via the event's returnValue property in IE, or
by the event handler returning false . |
boolean |
isPropagationStopped()
Indicates if event propagation is stopped.
|
void |
jsConstructor(String type,
net.sourceforge.htmlunit.corejs.javascript.ScriptableObject details)
JavaScript constructor.
|
void |
preventDefault()
If, during any stage of event flow, this method is called the event is canceled.
|
protected void |
setAltKey(boolean altKey)
Sets whether
ALT key is pressed on not. |
protected void |
setBubbles(boolean bubbles) |
protected void |
setCancelable(boolean cancelable) |
void |
setCancelBubble(boolean newValue) |
protected void |
setCtrlKey(boolean ctrlKey)
Sets whether
CTRL key is pressed on not. |
void |
setCurrentTarget(net.sourceforge.htmlunit.corejs.javascript.Scriptable target)
Sets the current target.
|
void |
setEventPhase(short phase)
Sets the current event phase.
|
void |
setEventType(String eventType)
Sets the event type.
|
protected void |
setKeyCode(Object keyCode)
Sets the key code.
|
void |
setReturnValue(Object returnValue)
Sets the return value associated with the event.
|
protected void |
setShiftKey(boolean shiftKey)
Sets whether
SHIFT key is pressed on not. |
void |
setSrcElement(Object srcElement)
Sets the object that fired the event.
|
void |
setTarget(Object target)
Sets the event target.
|
void |
setType(String type)
Sets the event type.
|
void |
startFire()
Called when the event starts being fired.
|
void |
stopPropagation()
Stops the event from propagating.
|
String |
toString() |
clone, equivalentValues, get, getBrowserVersion, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getWindow, getWindow, getWithPreemption, has, hasInstance, initParentScope, isReadOnlySettable, makeScriptableFor, setCaseSensitive, setDomNode, setDomNode, setHtmlElement
defineFunctionProperties, defineProperty, getClassName, setClassName, setParentScope
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setExternalArrayData, setGetterOrSetter, setPrototype, size
protected static final String KEY_CURRENT_EVENT
public static final String TYPE_SUBMIT
onsubmit
event handlers.public static final String TYPE_CHANGE
onchange
event handlers.public static final String TYPE_LOAD
onload
event handlers.public static final String TYPE_UNLOAD
onunload
event handlers.public static final String TYPE_POPSTATE
onpopstate
event handlers.public static final String TYPE_FOCUS
onfocus
event handlers.public static final String TYPE_FOCUS_IN
onfocusin
event handlers.public static final String TYPE_FOCUS_OUT
onfocusout
event handlers.public static final String TYPE_BLUR
onblur
event handlers.public static final String TYPE_KEY_DOWN
onkeydown
event handlers.public static final String TYPE_KEY_PRESS
onkeypress
event handlers.public static final String TYPE_INPUT
oninput
event handlers.public static final String TYPE_KEY_UP
onkeyup
event handlers.public static final String TYPE_RESET
onreset
event handlers.public static final String TYPE_BEFORE_UNLOAD
onbeforeunload
event handlers.public static final String TYPE_DOM_DOCUMENT_LOADED
public static final String TYPE_PROPERTY_CHANGE
onpropertychange
event handlers.public static final String TYPE_HASH_CHANGE
onhashchange
event handlers.public static final String TYPE_READY_STATE_CHANGE
onreadystatechange
event handlers.public static final String TYPE_ERROR
onerror
event handlers.public static final String TYPE_MESSAGE
public static final String TYPE_CLOSE
onclose
event handlers.public static final String TYPE_OPEN
onopen
event handlers.public static final short NONE
public static final short CAPTURING_PHASE
public static final short AT_TARGET
public static final short BUBBLING_PHASE
public static final int BLUR
public static final int CHANGE
public static final int CLICK
public static final int DBLCLICK
public static final int DRAGDROP
public static final int FOCUS
public static final int KEYDOWN
public static final int KEYPRESS
public static final int KEYUP
public static final int MOUSEDOWN
public static final int MOUSEDRAG
public static final int MOUSEMOVE
public static final int MOUSEOUT
public static final int MOUSEOVER
public static final int MOUSEUP
public static final int SELECT
public static final int ALT_MASK
public static final int CONTROL_MASK
public static final int SHIFT_MASK
public static final int META_MASK
public Event(DomNode domNode, String type)
domNode
- the DOM node that triggered the eventtype
- the event typepublic Event(SimpleScriptable scriptable, String type)
scriptable
- the SimpleScriptable that triggered the eventtype
- the event typepublic Event()
public static Event createPropertyChangeEvent(DomNode domNode, String propertyName)
TYPE_PROPERTY_CHANGE
type.domNode
- the DOM node that triggered the eventpropertyName
- the property name that was changedpublic void eventCreated()
Document.createEvent(..)
.
This method is called after the parent scope was set so you are able to access the browser version.public void jsConstructor(String type, net.sourceforge.htmlunit.corejs.javascript.ScriptableObject details)
type
- the event typedetails
- the event details (optional)public void startFire()
public void endFire()
public Object getSrcElement()
public void setSrcElement(Object srcElement)
srcElement
- the object that fired the eventpublic Object getTarget()
public void setTarget(Object target)
target
- the event targetpublic net.sourceforge.htmlunit.corejs.javascript.Scriptable getCurrentTarget()
public void setCurrentTarget(net.sourceforge.htmlunit.corejs.javascript.Scriptable target)
target
- the new valuepublic String getType()
public void setType(String type)
type
- the event typepublic void setEventType(String eventType)
eventType
- the event typepublic long getTimeStamp()
protected void setKeyCode(Object keyCode)
keyCode
- the virtual key code value of the key which was depressed, otherwise zeropublic Object getKeyCode()
public boolean getShiftKey()
SHIFT
has been pressed during this event or not.SHIFT
has been pressed during this event or notprotected void setShiftKey(boolean shiftKey)
SHIFT
key is pressed on not.shiftKey
- whether SHIFT
has been pressed during this event or notpublic boolean getCtrlKey()
CTRL
has been pressed during this event or not.CTRL
has been pressed during this event or notprotected void setCtrlKey(boolean ctrlKey)
CTRL
key is pressed on not.ctrlKey
- whether CTRL
has been pressed during this event or notpublic boolean getAltKey()
ALT
has been pressed during this event or not.ALT
has been pressed during this event or notprotected void setAltKey(boolean altKey)
ALT
key is pressed on not.altKey
- whether ALT
has been pressed during this event or notpublic int getEventPhase()
public void setEventPhase(short phase)
phase
- the phase the event is inpublic boolean getBubbles()
protected void setBubbles(boolean bubbles)
bubbles
- the bubbles to setpublic boolean getCancelable()
protected void setCancelable(boolean cancelable)
cancelable
- the cancelable to setpublic boolean getDefaultPrevented()
true
if both cancelable is true
and preventDefault() has been
called for this event. Otherwise this attribute must return false
.true
if this event has been cancelled or notpublic boolean getCancelBubble()
public void setCancelBubble(boolean newValue)
newValue
- indicates if event propagation is stoppedpublic void stopPropagation()
public boolean isPropagationStopped()
public Object getReturnValue()
public void setReturnValue(Object returnValue)
returnValue
- the return value associated with the eventpublic String getPropertyName()
public void initEvent(String type, boolean bubbles, boolean cancelable)
type
- the event typebubbles
- whether or not the event should bubblecancelable
- whether or not the event the event should be cancelablepublic void preventDefault()
public boolean isAborted(ScriptResult result)
true
if this event has been aborted via preventDefault() in
standards-compliant browsers, or via the event's returnValue property in IE, or
by the event handler returning false
.result
- the event handler result (if false
, the event is considered aborted)true
if this event has been abortedCopyright © 2002–2017 Gargoyle Software Inc.. All rights reserved.