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, Map, 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: 5864 $
Author:
Marc Guillemot, Ahmed Ashour
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
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_INPUT, TYPE_KEY_DOWN, TYPE_KEY_PRESS, TYPE_KEY_UP, TYPE_LOAD, 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
static MouseEvent getCurrentMouseEvent()
          Returns the mouse event currently firing, or null if no mouse event is being processed.
 void jsxFunction_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.
 int jsxGet_button()
          Gets the button code.
 int jsxGet_clientX()
          The horizontal coordinate at which the event occurred relative to the DOM implementation's client area.
 int jsxGet_clientY()
          The vertical coordinate at which the event occurred relative to the DOM implementation's client area.
 int jsxGet_pageX()
          Returns the horizontal coordinate of the event relative to whole document..
 int jsxGet_pageY()
          Returns the vertical coordinate of the event relative to the whole document.
 int jsxGet_screenX()
          The horizontal coordinate at which the event occurred relative to the origin of the screen coordinate system.
 int jsxGet_screenY()
          The vertical coordinate at which the event occurred relative to the origin of the screen coordinate system.
 int jsxGet_which()
          Special for FF (old stuff from Netscape time).
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.host.UIEvent
jsxFunction_initUIEvent, jsxGet_detail, jsxGet_metaKey, jsxGet_view, setDetail, setMetaKey
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.host.Event
applies, createPropertyChangeEvent, isAborted, isPropagationStopped, jsxFunction_initEvent, jsxFunction_preventDefault, jsxFunction_stopPropagation, jsxGet_altKey, jsxGet_bubbles, jsxGet_cancelable, jsxGet_cancelBubble, jsxGet_ctrlKey, jsxGet_currentTarget, jsxGet_eventPhase, jsxGet_keyCode, jsxGet_propertyName, jsxGet_returnValue, jsxGet_shiftKey, jsxGet_srcElement, jsxGet_target, jsxGet_timeStamp, jsxGet_type, jsxSet_cancelBubble, jsxSet_returnValue, jsxSet_srcElement, setAltKey, setCtrlKey, setCurrentTarget, setEventPhase, setEventType, setKeyCode, setShiftKey, setTarget, 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, makeScriptableFor, setCaseSensitive, setDomNode, setDomNode, setHtmlElement
 
Methods inherited from class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, clear, containsKey, containsValue, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineOwnProperties, defineOwnProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, entrySet, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypeOf, has, has, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, keySet, preventExtensions, put, put, put, putAll, putConst, putConstProperty, putProperty, putProperty, redefineProperty, remove, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setParentScope, setPrototype, size, values
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

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

jsxGet_clientX

public int jsxGet_clientX()
The horizontal coordinate at which the event occurred relative to the DOM implementation's client area.

Returns:
the horizontal coordinate

jsxGet_screenX

public int jsxGet_screenX()
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

jsxGet_pageX

public int jsxGet_pageX()
Returns the horizontal coordinate of the event relative to whole document..

Returns:
the horizontal coordinate (currently the same as jsxGet_screenX())
See Also:
Mozilla doc

jsxGet_clientY

public int jsxGet_clientY()
The vertical coordinate at which the event occurred relative to the DOM implementation's client area.

Returns:
the horizontal coordinate

jsxGet_screenY

public int jsxGet_screenY()
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

jsxGet_pageY

public int jsxGet_pageY()
Returns the vertical coordinate of the event relative to the whole document.

Returns:
the horizontal coordinate (currently the same as jsxGet_screenY())
See Also:
Mozilla doc

jsxGet_button

public int jsxGet_button()
Gets the button code.

Returns:
the button code

jsxGet_which

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

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

jsxFunction_initMouseEvent

public void jsxFunction_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


Copyright © 2002-2011 Gargoyle Software Inc.. All Rights Reserved.