Class MouseEvent
java.lang.Object
org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.javascript.HtmlUnitScriptable
org.htmlunit.javascript.host.event.Event
org.htmlunit.javascript.host.event.UIEvent
org.htmlunit.javascript.host.event.MouseEvent
- All Implemented Interfaces:
Serializable,Cloneable,org.htmlunit.corejs.javascript.ConstProperties,org.htmlunit.corejs.javascript.debug.DebuggableObject,org.htmlunit.corejs.javascript.Scriptable,org.htmlunit.corejs.javascript.SymbolScriptable
- Direct Known Subclasses:
DragEvent,MouseScrollEvent,PointerEvent,WheelEvent
JavaScript object representing a Mouse Event.
For general information on which properties and functions should be supported, see
DOM Level 2 Events.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intThe button code according to W3C (0: left button, 1: middle button, 2: right button).static final intThe code for left mouse button.static final intThe code for middle mouse button.static final intThe code for right mouse button.private intThe buttons being depressed (if any) when the mouse event was fired.private IntegerThe event's client coordinates; initiallynulland lazily initialized for performance reasons.private Integerprivate booleanWhether or not the "meta" key was pressed during the firing of the event.static final intConstant forMOZ_SOURCE_CURSOR.static final intConstant forMOZ_SOURCE_ERASER.static final intConstant forMOZ_SOURCE_KEYBOARD.static final intConstant forMOZ_SOURCE_MOUSE.static final intConstant forMOZ_SOURCE_PEN.static final intConstant forMOZ_SOURCE_TOUCH.static final intConstant forMOZ_SOURCE_UNKNOWN.private booleanSwitch to disable label handling if we already processing the event triggered from label processingprivate IntegerThe event's screen coordinates; initiallynulland lazily initialized for performance reasons.private Integerstatic final StringThe click event type, triggered byonclickevent handlers.static final StringThe context menu event type, triggered byoncontextmenuevent handlers.static final StringThe dblclick event type, triggered byondblclickevent handlers.static final StringThe mouse down event type, triggered byonmousedownevent handlers.static final StringThe mouse move event type, triggered byonmousemoveevent handlers.static final StringThe mouse out event type, triggered byonmouseoutevent handlers.static final StringThe mouse over event type, triggered byonmouseoverevent handlers.static final StringThe mouse up event type, triggered byonmouseupevent handlers.Fields inherited from class org.htmlunit.javascript.host.event.UIEvent
SCROLL_PAGE_DOWN, SCROLL_PAGE_UPFields inherited from class org.htmlunit.javascript.host.event.Event
ALT_MASK, AT_TARGET, BUBBLING_PHASE, CAPTURING_PHASE, CONTROL_MASK, KEY_CURRENT_EVENT, META_MASK, NONE, SHIFT_MASK, TYPE_ABORT, TYPE_AFTERPRINT, TYPE_AFTERSCRIPTEXECUTE, TYPE_ANIMATIONCANCEL, TYPE_ANIMATIONEND, TYPE_ANIMATIONITERATION, TYPE_ANIMATIONSTART, TYPE_AUXCLICK, TYPE_BEFORE_UNLOAD, TYPE_BEFORECOPY, TYPE_BEFORECUT, TYPE_BEFOREPASTE, TYPE_BEFOREPRINT, TYPE_BEFORESCRIPTEXECUTE, TYPE_BLUR, TYPE_CANCEL, TYPE_CANPLAY, TYPE_CANPLAYTHROUGH, TYPE_CHANGE, TYPE_CLOSE, TYPE_COPY, TYPE_CUECHANGE, TYPE_CUT, TYPE_DEVICEMOTION, TYPE_DEVICEORIENTATION, TYPE_DEVICEORIENTATIONABSOLUTE, TYPE_DOM_DOCUMENT_LOADED, TYPE_DRAG, TYPE_DRAGEND, TYPE_DRAGENTER, TYPE_DRAGLEAVE, TYPE_DRAGOVER, TYPE_DRAGSTART, TYPE_DROP, TYPE_DURATIONCHANGE, TYPE_EMPTIED, TYPE_ENDED, TYPE_ERROR, TYPE_FOCUS, TYPE_FOCUS_IN, TYPE_FOCUS_OUT, TYPE_GAMEPAD_CONNECTED, TYPE_GAMEPAD_DISCONNECTED, TYPE_GOTPOINTERCAPTURE, TYPE_HASH_CHANGE, TYPE_INPUT, TYPE_INVALID, TYPE_KEY_DOWN, TYPE_KEY_PRESS, TYPE_KEY_UP, TYPE_LANGUAGECHANGE, TYPE_LOAD, TYPE_LOAD_END, TYPE_LOAD_START, TYPE_LOADEDDATA, TYPE_LOADEDMETADATA, TYPE_LOSTPOINTERCAPTURE, TYPE_MESSAGE, TYPE_MOUDEENTER, TYPE_MOUSELEAVE, TYPE_MOUSEWHEEL, TYPE_MOZFULLSCREENCHANGE, TYPE_MOZFULLSCREENERROR, TYPE_MSSITEMODEJUMPLISTITEMREMOVED, TYPE_OFFLINE, TYPE_ONLINE, TYPE_ONMESSAGEERROR, TYPE_ONTRANSITIONCANCEL, TYPE_ONTRANSITIONEND, TYPE_ONTRANSITIONRUN, TYPE_ONTRANSITIONSTART, TYPE_OPEN, TYPE_PAGEHIDE, TYPE_PAGESHOW, TYPE_PASTE, TYPE_PAUSE, TYPE_PLAY, TYPE_PLAYING, TYPE_POINTERCANCEL, TYPE_POINTERDOWN, TYPE_POINTERENTER, TYPE_POINTERLEAVE, TYPE_POINTERLOCKCHANGE, TYPE_POINTERLOCKERROR, TYPE_POINTERMOVE, TYPE_POINTEROUT, TYPE_POINTEROVER, TYPE_POINTERUP, TYPE_POPSTATE, TYPE_PROGRESS, TYPE_PROPERTY_CHANGE, TYPE_RATECHANGE, TYPE_READY_STATE_CHANGE, TYPE_REJECTIONHANDLED, TYPE_RESET, TYPE_RESIZE, TYPE_SCROLL, TYPE_SCROLLEND, TYPE_SEARCH, TYPE_SEEKED, TYPE_SEEKING, TYPE_SELECT, TYPE_SELECTIONCHANGE, TYPE_SELECTSTART, TYPE_STALLED, TYPE_STORAGE, TYPE_SUBMIT, TYPE_SUSPEND, TYPE_TIMEOUT, TYPE_TIMEUPDATE, TYPE_TOGGLE, TYPE_TRANSITIONEND, TYPE_UNHANDLEDREJECTION, TYPE_UNLOAD, TYPE_VOLUMECHANGE, TYPE_WAITING, TYPE_WEBANIMATIONSTART, TYPE_WEBKITANIMATIONEND, TYPE_WEBKITANIMATIONITERATION, TYPE_WEBKITFULLSCREENCHANGE, TYPE_WEBKITFULLSCREENERROR, TYPE_WEBKITTRANSITIONEND, TYPE_WHEELFields inherited from class org.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONSTFields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND -
Constructor Summary
ConstructorsConstructorDescriptionUsed to build the prototype.MouseEvent(DomNode domNode, String type, boolean shiftKey, boolean ctrlKey, boolean altKey, int button, int detail) Creates a new event instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidDisable the lable processing if we are already processing one.intGets the button code.intGets the button code.intThe horizontal coordinate at which the event occurred relative to the DOM implementation's client area.intThe vertical coordinate at which the event occurred relative to the DOM implementation's client area.static MouseEventReturns the mouse event currently firing, ornullif no mouse event is being processed.booleanReturns whether or not the "meta" key was pressed during the event firing.intgetPageX()Returns the horizontal coordinate of the event relative to whole document..intgetPageY()Returns the vertical coordinate of the event relative to the whole document.intThe horizontal coordinate at which the event occurred relative to the origin of the screen coordinate system.intThe vertical coordinate at which the event occurred relative to the origin of the screen coordinate system.intgetWhich()Special for FF (old stuff from Netscape time).voidinitMouseEvent(String type, boolean bubbles, boolean cancelable, Object view, int detail, int screenX, int screenY, int clientX, int clientY, boolean ctrlKey, boolean altKey, boolean shiftKey, boolean metaKey, int button, Object relatedTarget) Implementation of the DOM Level 2 Event method for initializing the mouse event.booleanisAltKey()Returns whetherALThas been pressed during this event or not.booleanReturns whetherCTRLhas been pressed during this event or not.static booleanisMouseEvent(String type) Returnstrueif the specified event type should be managed as a mouse event.booleanReturns whetherSHIFThas been pressed during this event or not.voidjsConstructor(String type, org.htmlunit.corejs.javascript.ScriptableObject details) JavaScript constructor.booleanINTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
If we click on a label, we have to simulate a click on the element referenced by the 'for' attribute also.voidsetButton(int value) Sets the button code.voidsetButtons(int value) Sets the button code.voidsetClientX(int value) Sets the clientX value.voidsetClientY(int value) Sets the clientY value.protected voidsetMetaKey(boolean metaKey) Methods inherited from class org.htmlunit.javascript.host.event.UIEvent
getDetail, getView, initUIEvent, setDetailMethods inherited from class org.htmlunit.javascript.host.event.Event
createPropertyChangeEvent, endFire, eventCreated, getComposed, getCurrentTarget, getEventPhase, getKeyCode, getPropertyName, getReturnValue, getSrcElement, getTarget, getTimeStamp, getType, handlePropertyHandlerReturnValue, initEvent, isAborted, isBubbles, isCancelable, isCancelBubble, isDefaultPrevented, isImmediatePropagationStopped, isMissingOrUndefined, isPropagationStopped, preventDefault, setAltKey, setBubbles, setCancelable, setCancelBubble, setCtrlKey, setCurrentTarget, setEventPhase, setEventType, setKeyCode, setReturnValue, setShiftKey, setSrcElement, setTarget, setType, startFire, stopImmediatePropagation, stopPropagation, toStringMethods inherited from class org.htmlunit.javascript.HtmlUnitScriptable
clone, equivalentValues, get, getBrowserVersion, getClassName, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getWindow, getWindow, getWithPreemption, has, hasInstance, initParentScope, makeScriptableFor, put, setClassName, setDomNode, setDomNode, setParentScope, setupPromise, setupRejectedPromiseMethods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setPrototype, size
-
Field Details
-
MOZ_SOURCE_UNKNOWN
public static final int MOZ_SOURCE_UNKNOWNConstant forMOZ_SOURCE_UNKNOWN.- See Also:
-
MOZ_SOURCE_MOUSE
public static final int MOZ_SOURCE_MOUSEConstant forMOZ_SOURCE_MOUSE.- See Also:
-
MOZ_SOURCE_PEN
public static final int MOZ_SOURCE_PENConstant forMOZ_SOURCE_PEN.- See Also:
-
MOZ_SOURCE_ERASER
public static final int MOZ_SOURCE_ERASERConstant forMOZ_SOURCE_ERASER.- See Also:
-
MOZ_SOURCE_CURSOR
public static final int MOZ_SOURCE_CURSORConstant forMOZ_SOURCE_CURSOR.- See Also:
-
MOZ_SOURCE_TOUCH
public static final int MOZ_SOURCE_TOUCHConstant forMOZ_SOURCE_TOUCH.- See Also:
-
MOZ_SOURCE_KEYBOARD
public static final int MOZ_SOURCE_KEYBOARDConstant forMOZ_SOURCE_KEYBOARD.- See Also:
-
TYPE_CLICK
The click event type, triggered byonclickevent handlers.- See Also:
-
TYPE_DBL_CLICK
The dblclick event type, triggered byondblclickevent handlers.- See Also:
-
TYPE_MOUSE_OVER
The mouse over event type, triggered byonmouseoverevent handlers.- See Also:
-
TYPE_MOUSE_MOVE
The mouse move event type, triggered byonmousemoveevent handlers.- See Also:
-
TYPE_MOUSE_OUT
The mouse out event type, triggered byonmouseoutevent handlers.- See Also:
-
TYPE_MOUSE_DOWN
The mouse down event type, triggered byonmousedownevent handlers.- See Also:
-
TYPE_MOUSE_UP
The mouse up event type, triggered byonmouseupevent handlers.- See Also:
-
TYPE_CONTEXT_MENU
The context menu event type, triggered byoncontextmenuevent handlers.- See Also:
-
BUTTON_LEFT
public static final int BUTTON_LEFTThe code for left mouse button.- See Also:
-
BUTTON_MIDDLE
public static final int BUTTON_MIDDLEThe code for middle mouse button.- See Also:
-
BUTTON_RIGHT
public static final int BUTTON_RIGHTThe code for right mouse button.- See Also:
-
screenX_
The event's screen coordinates; initiallynulland lazily initialized for performance reasons. -
screenY_
-
clientX_
The event's client coordinates; initiallynulland lazily initialized for performance reasons. -
clientY_
-
button_
private int button_The button code according to W3C (0: left button, 1: middle button, 2: right button). -
buttons_
private int buttons_The buttons being depressed (if any) when the mouse event was fired. -
processLabelAfterBubbling_
private boolean processLabelAfterBubbling_Switch to disable label handling if we already processing the event triggered from label processing -
metaKey_
private boolean metaKey_Whether or not the "meta" key was pressed during the firing of the event.
-
-
Constructor Details
-
MouseEvent
public MouseEvent()Used to build the prototype. -
MouseEvent
public MouseEvent(DomNode domNode, String type, boolean shiftKey, boolean ctrlKey, boolean altKey, int button, int detail) Creates a new event instance.- Parameters:
domNode- the DOM node that triggered the eventtype- the event typeshiftKey- true if SHIFT is pressedctrlKey- true if CTRL is pressedaltKey- true if ALT is pressedbutton- the button code, must beBUTTON_LEFT,BUTTON_MIDDLEorBUTTON_RIGHTdetail- the detail value
-
-
Method Details
-
jsConstructor
JavaScript constructor.- Overrides:
jsConstructorin classUIEvent- Parameters:
type- the event typedetails- the event details (optional)
-
getClientX
public int getClientX()The horizontal coordinate at which the event occurred relative to the DOM implementation's client area.- Returns:
- the horizontal coordinate
-
setClientX
public void setClientX(int value) Sets the clientX value.- Parameters:
value- the clientX value
-
getScreenX
public int getScreenX()The horizontal coordinate at which the event occurred relative to the origin of the screen coordinate system. The value of this attribute is initialized lazily, in order to optimize performance (it requires CSS parsing).- Returns:
- the horizontal coordinate
-
getPageX
public int getPageX()Returns the horizontal coordinate of the event relative to whole document..- Returns:
- the horizontal coordinate (currently the same as
getScreenX()) - See Also:
-
getClientY
public int getClientY()The vertical coordinate at which the event occurred relative to the DOM implementation's client area.- Returns:
- the horizontal coordinate
-
setClientY
public void setClientY(int value) Sets the clientY value.- Parameters:
value- the clientY value
-
getScreenY
public int getScreenY()The vertical coordinate at which the event occurred relative to the origin of the screen coordinate system. The value of this attribute is initialized lazily, in order to optimize performance (it requires CSS parsing).- Returns:
- the vertical coordinate
-
getPageY
public int getPageY()Returns the vertical coordinate of the event relative to the whole document.- Returns:
- the horizontal coordinate (currently the same as
getScreenY()) - See Also:
-
getButton
public int getButton()Gets the button code.- Returns:
- the button code
-
setButton
public void setButton(int value) Sets the button code.- Parameters:
value- the button code
-
getButtons
public int getButtons()Gets the button code.- Returns:
- the button code
-
setButtons
public void setButtons(int value) Sets the button code.- Parameters:
value- the button code
-
getWhich
public int getWhich()Special for FF (old stuff from Netscape time). -
initMouseEvent
public void initMouseEvent(String type, boolean bubbles, boolean cancelable, Object view, int detail, int screenX, int screenY, int clientX, int clientY, boolean ctrlKey, boolean altKey, boolean shiftKey, boolean metaKey, int button, Object relatedTarget) Implementation of the DOM Level 2 Event method for initializing the mouse event.- Parameters:
type- the event typebubbles- can the event bubblecancelable- can the event be canceledview- the view to use for this eventdetail- the detail to set for the eventscreenX- the initial value of screenXscreenY- the initial value of screenYclientX- the initial value of clientXclientY- the initial value of clientYctrlKey- is the control key pressedaltKey- is the alt key pressedshiftKey- is the shift key pressedmetaKey- is the meta key pressedbutton- what mouse button is pressedrelatedTarget- is there a related target for the event
-
getCurrentMouseEvent
Returns the mouse event currently firing, ornullif no mouse event is being processed.- Returns:
- the mouse event currently firing
-
isMouseEvent
Returnstrueif the specified event type should be managed as a mouse event.- Parameters:
type- the type of event to check- Returns:
trueif the specified event type should be managed as a mouse event
-
isAltKey
public boolean isAltKey()Returns whetherALThas been pressed during this event or not. Overridden to modify browser configurations. -
isCtrlKey
public boolean isCtrlKey()Returns whetherCTRLhas been pressed during this event or not. Overridden to modify browser configurations. -
isShiftKey
public boolean isShiftKey()Returns whetherSHIFThas been pressed during this event or not. Overridden to modify browser configurations.- Overrides:
isShiftKeyin classEvent- Returns:
- whether
SHIFThas been pressed during this event or not
-
processLabelAfterBubbling
public boolean processLabelAfterBubbling()INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
If we click on a label, we have to simulate a click on the element referenced by the 'for' attribute also. To support this for special events we have this method here. Overridden take care of click events.- Overrides:
processLabelAfterBubblingin classEvent- Returns:
- false in this default impl
-
disableProcessLabelAfterBubbling
public void disableProcessLabelAfterBubbling()Disable the lable processing if we are already processing one. -
getMetaKey
public boolean getMetaKey()Returns whether or not the "meta" key was pressed during the event firing.- Returns:
- whether or not the "meta" key was pressed during the event firing
-
setMetaKey
protected void setMetaKey(boolean metaKey) - Parameters:
metaKey- whether Meta has been pressed during this event or not
-