com.gargoylesoftware.htmlunit.javascript.host
Class MouseEvent

java.lang.Object
  extended by net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
      extended by com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
          extended by com.gargoylesoftware.htmlunit.javascript.host.Event
              extended by com.gargoylesoftware.htmlunit.javascript.host.UIEvent
                  extended by com.gargoylesoftware.htmlunit.javascript.host.MouseEvent
All Implemented Interfaces:
Serializable, Cloneable, net.sourceforge.htmlunit.corejs.javascript.ConstProperties, net.sourceforge.htmlunit.corejs.javascript.debug.DebuggableObject, net.sourceforge.htmlunit.corejs.javascript.Scriptable

public class MouseEvent
extends UIEvent

JavaScript object representing a Mouse Event. For general information on which properties and functions should be supported, see DOM Level 2 Events.

Version:
$Revision: 7931 $
Author:
Marc Guillemot, Ahmed Ashour
See Also:
Serialized Form

Field Summary
static int BUTTON_LEFT
          The code for left mouse button.
static int BUTTON_MIDDLE
          The code for middle mouse button.
static int BUTTON_RIGHT
          The code for right mouse button.
static String TYPE_CLICK
          The click event type, triggered by "onclick" event handlers.
static String TYPE_CONTEXT_MENU
          The context menu event type, triggered by "oncontextmenu" event handlers.
static String TYPE_DBL_CLICK
          The dblclick event type, triggered by "ondblclick" event handlers.
static String TYPE_MOUSE_DOWN
          The mouse down event type, triggered by "onmousedown" event handlers.
static String TYPE_MOUSE_MOVE
          The mouse move event type, triggered by "onmousemove" event handlers.
static String TYPE_MOUSE_OUT
          The mouse out event type, triggered by "onmouseout" event handlers.
static String TYPE_MOUSE_OVER
          The mouse over event type, triggered by "onmouseover" event handlers.
static String TYPE_MOUSE_UP
          The mouse up event type, triggered by "onmouseup" event handlers.
 
Fields inherited from class com.gargoylesoftware.htmlunit.javascript.host.Event
ABORT, ALT_MASK, AT_TARGET, BACK, BLUR, BUBBLING_PHASE, CAPTURING_PHASE, CHANGE, CLICK, CONTROL_MASK, DBLCLICK, DRAGDROP, ERROR, FOCUS, FORWARD, HELP, KEYDOWN, KEYPRESS, KEYUP, LOAD, LOCATE, META_MASK, MOUSEDOWN, MOUSEDRAG, MOUSEMOVE, MOUSEOUT, MOUSEOVER, MOUSEUP, MOVE, RESET, RESIZE, SCROLL, SELECT, SHIFT_MASK, SUBMIT, TEXT, TYPE_BEFORE_UNLOAD, TYPE_BLUR, TYPE_CHANGE, TYPE_DOM_DOCUMENT_LOADED, TYPE_ERROR, TYPE_FOCUS, TYPE_FOCUS_IN, TYPE_FOCUS_OUT, TYPE_HASH_CHANGE, TYPE_INPUT, TYPE_KEY_DOWN, TYPE_KEY_PRESS, TYPE_KEY_UP, TYPE_LOAD, TYPE_MESSAGE, TYPE_PROPERTY_CHANGE, TYPE_READY_STATE_CHANGE, TYPE_RESET, TYPE_SUBMIT, TYPE_UNLOAD, UNLOAD, XFER_DONE
 
Fields inherited from class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
 
Fields inherited from interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
NOT_FOUND
 
Constructor Summary
MouseEvent()
          Used to build the prototype.
MouseEvent(DomNode domNode, String type, boolean shiftKey, boolean ctrlKey, boolean altKey, int button)
          Creates a new event instance.
 
Method Summary
 boolean getAltKey()
           Overridden to modify browser configurations.
 int getButton()
          Gets the button code.
 int getClientX()
          The horizontal coordinate at which the event occurred relative to the DOM implementation's client area.
 int getClientY()
          The vertical coordinate at which the event occurred relative to the DOM implementation's client area.
 boolean getCtrlKey()
           Overridden to modify browser configurations.
static MouseEvent getCurrentMouseEvent()
          Returns the mouse event currently firing, or null if no mouse event is being processed.
 int getPageX()
          Returns the horizontal coordinate of the event relative to whole document..
 int getPageY()
          Returns the vertical coordinate of the event relative to the whole document.
 int getScreenX()
          The horizontal coordinate at which the event occurred relative to the origin of the screen coordinate system.
 int getScreenY()
          The vertical coordinate at which the event occurred relative to the origin of the screen coordinate system.
 boolean getShiftKey()
           Overridden to modify browser configurations.
 int getWhich()
          Special for FF (old stuff from Netscape time).
 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.
 void setButton(int value)
          Sets the button code.
 void setClientX(int value)
          Sets the clientX value.
 void setClientY(int value)
          Sets the clientY value.
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.host.UIEvent
getDetail, getMetaKey, getView, initUIEvent, setDetail, setMetaKey
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.host.Event
applies, createPropertyChangeEvent, getBubbles, getCancelable, getCancelBubble, getCurrentTarget, getEventPhase, getKeyCode, getPropertyName, getReturnValue, getSrcElement, getTarget, getTimeStamp, getType, initEvent, isAborted, isPropagationStopped, preventDefault, setAltKey, setCancelBubble, setCtrlKey, setCurrentTarget, setEventPhase, setEventType, setKeyCode, setReturnValue, setShiftKey, setSrcElement, setTarget, setType, stopPropagation, toString
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
clone, defineFunctionProperties, defineProperty, equivalentValues, get, getBrowserVersion, getClassName, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getTransformerScriptableFor, getWindow, getWindow, getWithPreemption, hasInstance, initParentScope, isReadOnlySettable, makeScriptableFor, setCaseSensitive, setDomNode, setDomNode, setHtmlElement, setParentScope
 
Methods inherited from class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
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, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, 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, setGetterOrSetter, setPrototype, size
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_CLICK

public static final String TYPE_CLICK
The click event type, triggered by "onclick" event handlers.

See Also:
Constant Field Values

TYPE_DBL_CLICK

public static final String TYPE_DBL_CLICK
The dblclick event type, triggered by "ondblclick" event handlers.

See Also:
Constant Field Values

TYPE_MOUSE_OVER

public static final String TYPE_MOUSE_OVER
The mouse over event type, triggered by "onmouseover" event handlers.

See Also:
Constant Field Values

TYPE_MOUSE_MOVE

public static final String TYPE_MOUSE_MOVE
The mouse move event type, triggered by "onmousemove" event handlers.

See Also:
Constant Field Values

TYPE_MOUSE_OUT

public static final String TYPE_MOUSE_OUT
The mouse out event type, triggered by "onmouseout" event handlers.

See Also:
Constant Field Values

TYPE_MOUSE_DOWN

public static final String TYPE_MOUSE_DOWN
The mouse down event type, triggered by "onmousedown" event handlers.

See Also:
Constant Field Values

TYPE_MOUSE_UP

public static final String TYPE_MOUSE_UP
The mouse up event type, triggered by "onmouseup" event handlers.

See Also:
Constant Field Values

TYPE_CONTEXT_MENU

public static final String TYPE_CONTEXT_MENU
The context menu event type, triggered by "oncontextmenu" event handlers.

See Also:
Constant Field Values

BUTTON_LEFT

public static final int BUTTON_LEFT
The code for left mouse button.

See Also:
Constant Field Values

BUTTON_MIDDLE

public static final int BUTTON_MIDDLE
The code for middle mouse button.

See Also:
Constant Field Values

BUTTON_RIGHT

public static final int BUTTON_RIGHT
The code for right mouse button.

See Also:
Constant Field Values
Constructor Detail

MouseEvent

public MouseEvent()
Used to build the prototype.


MouseEvent

public MouseEvent(DomNode domNode,
                  String type,
                  boolean shiftKey,
                  boolean ctrlKey,
                  boolean altKey,
                  int button)
Creates a new event instance.

Parameters:
domNode - the DOM node that triggered the event
type - the event type
shiftKey - true if SHIFT is pressed
ctrlKey - true if CTRL is pressed
altKey - true if ALT is pressed
button - the button code, must be BUTTON_LEFT, BUTTON_MIDDLE or BUTTON_RIGHT
Method Detail

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:
Mozilla doc

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:
Mozilla doc

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

getWhich

public int getWhich()
Special for FF (old stuff from Netscape time).

Returns:
the button code
See Also:
Javascript Madness: Mouse Events

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 type
bubbles - can the event bubble
cancelable - can the event be canceled
view - the view to use for this event
detail - the detail to set for the event
screenX - the initial value of screenX
screenY - the initial value of screenY
clientX - the initial value of clientX
clientY - the initial value of clientY
ctrlKey - is the control key pressed
altKey - is the alt key pressed
shiftKey - is the shift key pressed
metaKey - is the meta key pressed
button - what mouse button is pressed
relatedTarget - is there a related target for the event

getCurrentMouseEvent

public static MouseEvent getCurrentMouseEvent()
Returns the mouse event currently firing, or null if no mouse event is being processed.

Returns:
the mouse event currently firing

getAltKey

public boolean getAltKey()
Overridden to modify browser configurations. Overridden to modify browser configurations.

Overrides:
getAltKey in class UIEvent
Returns:
whether ALT has been pressed during this event or not

getCtrlKey

public boolean getCtrlKey()
Overridden to modify browser configurations. Overridden to modify browser configurations.

Overrides:
getCtrlKey in class UIEvent
Returns:
whether CTRL has been pressed during this event or not

getShiftKey

public boolean getShiftKey()
Overridden to modify browser configurations. Overridden to modify browser configurations.

Overrides:
getShiftKey in class UIEvent
Returns:
whether SHIFT has been pressed during this event or not


Copyright © 2002–2013 Gargoyle Software Inc.. All rights reserved.