Constructor
new module:caplin/dom/event/Event()
module:caplin/dom/event/Event#getNormalizedEvent
method.
Members
-
altKey :boolean
-
Returns
true
if the "ALT" key was pressed when the event was triggered, otherwisefalse
.Type:
- boolean
-
button :int
-
Returns which mouse button was clicked when the event was triggered. Please see
module:caplin/dom/event/Event/MouseButtons
for the possible values.WARNING - The normalisation of the button in Internet Explorer is not suitable if the user is expected to press more than one mouse button at any one time. If they do so, then the normalised value will only indicate that one of the buttons has been pressed. For example if the user presses the LEFT and RIGHT mouse buttons, this value will be
Event.MouseButtons.LEFT
.Type:
- int
-
charCode :int
-
Returns the ascii code of the character that will be inserted due to a keypress event.
Type:
- int
-
clientX :int
-
Returns the horizontal coordinate of the mouse pointer when the event was triggered.
Type:
- int
-
clientY :int
-
Returns the vertical coordinate of the mouse pointer when the event was triggered.
Type:
- int
-
ctrlKey :boolean
-
Returns
true
if the "CTRL" key was pressed when the event was triggered, otherwisefalse
.Type:
- boolean
-
keyCode :int
-
Returns the code of the key during a keyUp or keyDown event. You should use this on keyUp or keyDown events. It contains a code indicating the hardware key that was pressed. This is not necessarily the same as the ascii character that will be inserted.
Type:
- int
-
relatedTarget :HtmlElement
-
Returns the element related to the actual target that triggered the event. For example when a
mouseout
event is fired, themodule:caplin/dom/event/Event#target
will refer to element that the mouse pointer is moving out of, whilst therelatedTarget
will refer to the element that is being moved into.Type:
- HtmlElement
-
screenX :int
-
Returns the horizontal coordinate of the mouse pointer when the event was triggered.
Type:
- int
-
screenY :int
-
Returns the vertical coordinate of the mouse pointer when the event was triggered.
Type:
- int
-
shiftKey :boolean
-
Returns
true
if the "SHIFT" key was pressed when the event was triggered, otherwisefalse
.Type:
- boolean
-
target :HtmlElement
-
Returns the element that triggered the event. For example when a
click
event is fired, this is the element that was clicked.Type:
- HtmlElement
-
type :String
-
Returns the name of the event.
Type:
- String
Methods
-
(static) cancelEventBubbling(eventObj)
-
Crossbrowser method for canceling event bubbling.
Parameters:
Name Type Description eventObj
Object The event object. -
(static) getEventSrc(eventObj:) → {Object}
-
Crossbrowser method for returning the DOM element that fired the event.
Parameters:
Name Type Description eventObj:
Object The event object Returns:
The DOM element where that fired the event- Type
- Object
-
(static) getNormalizedEvent(rawEvent) → {module:caplin/dom/event/Event}
-
Gets the normalised event that applies across all browsers representing the specified event.
Parameters:
Name Type Description rawEvent
HtmlEvent The event to be normalised. If this value is undefined
this method will use thewindow.event
.Throws:
-
if the rawEvent is
undefined
and thewindow.event
global does not exist.
Returns:
A normalised event. -
-
finalize()
-
Clean up any DOM references in the event.
-
getRawEvent() → {HtmlEvent}
-
Gets the underlying event that this normalised event was constructed from.
Returns:
The underlying event.- Type
- HtmlEvent
-
preventDefault()
-
Cancels the event if it is cancelable, without stopping further propagation of the event. This means that any default action normally taken as a result of the event will not occur (e.g. the key that was pressed will be ignored). This method does not stop further propagation of the event through the DOM (please see
module:caplin/dom/event/Event#stopPropagation
).Invoking this method for a non-cancelable event has no effect.
-
stopPropagation()
-
Prevents further propagation of the current event.