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 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 |
CONTROL_MASK
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 |
META_MASK
Constant.
|
static short |
NONE
No event phase.
|
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(EventTarget target,
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(..) |
net.sourceforge.htmlunit.corejs.javascript.Scriptable |
getCurrentTarget()
Returns the event target whose event listeners are currently being processed.
|
int |
getEventPhase()
Returns the current event phase for the event.
|
int |
getKeyCode()
Returns the key code associated with the event.
|
String |
getPropertyName()
Returns the property name associated with the event.
|
Object |
getReturnValue() |
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 |
isAltKey()
Returns whether
ALT has been pressed during this event or not. |
boolean |
isBubbles() |
boolean |
isCancelable() |
boolean |
isCancelBubble() |
boolean |
isCtrlKey()
Returns whether
CTRL has been pressed during this event or not. |
boolean |
isDefaultPrevented()
Returns
true if both cancelable is true and preventDefault() has been
called for this event. |
boolean |
isImmediatePropagationStopped()
Indicates if event immediate propagation is stopped.
|
boolean |
isPropagationStopped()
Indicates if event propagation is stopped.
|
boolean |
isShiftKey()
Returns whether
SHIFT has been pressed during this event or not. |
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.
|
boolean |
processLabelAfterBubbling()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
|
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(int keyCode)
Sets the key code.
|
void |
setReturnValue(Object newValue) |
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(EventTarget target)
Sets the event target.
|
void |
setType(String type)
Sets the event type.
|
void |
startFire()
Called when the event starts being fired.
|
void |
stopImmediatePropagation()
Prevents other listeners of the same event from being called.
|
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, makeScriptableFor, setCaseSensitive, setDomNode, setDomNode, setHtmlElementdefineFunctionProperties, defineProperty, getClassName, put, setClassName, setParentScopeapplyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isReadOnlySettable, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, putProperty, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setExternalArrayData, setGetterOrSetter, setPrototype, sizeprotected 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 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(EventTarget target, String type)
target - the targettype - 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(EventTarget 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(int keyCode)
keyCode - the virtual key code value of the key which was depressed, otherwise zeropublic int getKeyCode()
public boolean isShiftKey()
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 isCtrlKey()
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 isAltKey()
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 isBubbles()
protected void setBubbles(boolean bubbles)
bubbles - the bubbles to setpublic boolean isCancelable()
protected void setCancelable(boolean cancelable)
cancelable - the cancelable to setpublic boolean isDefaultPrevented()
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 isCancelBubble()
public void setCancelBubble(boolean newValue)
newValue - indicates if event propagation is stoppedpublic void stopPropagation()
public boolean isPropagationStopped()
public void stopImmediatePropagation()
public boolean isImmediatePropagationStopped()
public 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 abortedpublic boolean processLabelAfterBubbling()
public Object getReturnValue()
public void setReturnValue(Object newValue)
newValue - the new return valueCopyright © 2002–2020 Gargoyle Software Inc.. All rights reserved.