Print Friendly

Class Ext.EventObject

Package:Ext
Class:EventObject
Extends:Object
Defined In:EventManager.js
EventObject exposes the Yahoo! UI Event functionality directly on the object passed to your event handler. It exists mostly for convenience. It also fixes the annoying null checks automatically to cleanup your code Example:
function handleClick(e){ // e is not a standard event object, it is a Ext.EventObject
    e.preventDefault();
    var target = e.getTarget();
    ...
 }
 var myDiv = Ext.get("myDiv");
 myDiv.on("click", handleClick);
 //or
 Ext.EventManager.on("myDiv", 'click', handleClick);
 Ext.EventManager.addListener("myDiv", 'click', handleClick);


This class is a singleton and cannot be created directly.

Properties   -  Methods   -  Events

Public Properties

Property Defined By
  BACKSPACE : Number EventObject
Key constant
  CONTROL : Number EventObject
Key constant
  DELETE : Number EventObject
Key constant
  DOWN : Number EventObject
Key constant
  END : Number EventObject
Key constant
  ENTER : Number EventObject
Key constant
  ESC : Number EventObject
Key constant
  F5 : Number EventObject
Key constant
  HOME : Number EventObject
Key constant
  LEFT : Number EventObject
Key constant
  PAGEDOWN : Number EventObject
Key constant
  PAGEUP : Number EventObject
Key constant
  RETURN : Number EventObject
Key constant
  RIGHT : Number EventObject
Key constant
  SHIFT : Number EventObject
Key constant
  SPACE : Number EventObject
Key constant
  TAB : Number EventObject
Key constant
  UP : Number EventObject
Key constant
  altKey : Object EventObject
True if the alt key was down during the event
  browserEvent : Object EventObject
The normal browser event
  button : Object EventObject
The button pressed in a mouse event
  ctrlKey : Object EventObject
True if the control key was down during the event
  shiftKey : Object EventObject
True if the shift key was down during the event

Public Methods

Method Defined By
  getCharCode() : Number EventObject
Gets the key code for the event.
  getKey() : Number EventObject
Returns a normalized keyCode for the event.
  getPageX() : Number EventObject
Gets the x coordinate of the event.
  getPageY() : Number EventObject
Gets the y coordinate of the event.
  getRelatedTarget() : HTMLElement EventObject
Gets the related target.
  getTarget[String selector], [Number/String/HTMLElement/Element maxDepth], [Boolean returnEl] ) : HTMLelement EventObject
Gets the target for the event.
  getTime() : Number EventObject
Gets the time of the event.
  getWheelDelta() : Number EventObject
Normalizes mouse wheel delta across browsers
  getXY() : Array EventObject
Gets the page coordinates of the event.
  hasModifier() : Boolean EventObject
Returns true if the control, meta, shift or alt key was pressed during this event.
  preventDefault() : void EventObject
Prevents the browsers default handling of the event.
  stopEvent() : void EventObject
Stop the event (preventDefault and stopPropagation)
  stopPropagation() : void EventObject
Cancels bubbling of the event.
  withinString/HTMLElement/Element el, [Boolean related] ) : Boolean EventObject
Returns true if the target of this event equals el or is a child of el

Public Events

This class has no public events.

Property Details

BACKSPACE

public Number BACKSPACE
Key constant
This property is defined by EventObject.

CONTROL

public Number CONTROL
Key constant
This property is defined by EventObject.

DELETE

public Number DELETE
Key constant
This property is defined by EventObject.

DOWN

public Number DOWN
Key constant
This property is defined by EventObject.

END

public Number END
Key constant
This property is defined by EventObject.

ENTER

public Number ENTER
Key constant
This property is defined by EventObject.

ESC

public Number ESC
Key constant
This property is defined by EventObject.

F5

public Number F5
Key constant
This property is defined by EventObject.

HOME

public Number HOME
Key constant
This property is defined by EventObject.

LEFT

public Number LEFT
Key constant
This property is defined by EventObject.

PAGEDOWN

public Number PAGEDOWN
Key constant
This property is defined by EventObject.

PAGEUP

public Number PAGEUP
Key constant
This property is defined by EventObject.

RETURN

public Number RETURN
Key constant
This property is defined by EventObject.

RIGHT

public Number RIGHT
Key constant
This property is defined by EventObject.

SHIFT

public Number SHIFT
Key constant
This property is defined by EventObject.

SPACE

public Number SPACE
Key constant
This property is defined by EventObject.

TAB

public Number TAB
Key constant
This property is defined by EventObject.

UP

public Number UP
Key constant
This property is defined by EventObject.

altKey

public Object altKey
True if the alt key was down during the event
This property is defined by EventObject.

browserEvent

public Object browserEvent
The normal browser event
This property is defined by EventObject.

button

public Object button
The button pressed in a mouse event
This property is defined by EventObject.

ctrlKey

public Object ctrlKey
True if the control key was down during the event
This property is defined by EventObject.

shiftKey

public Object shiftKey
True if the shift key was down during the event
This property is defined by EventObject.

Method Details

getCharCode

public function getCharCode()
Gets the key code for the event.
Parameters:
  • None.
Returns:
  • Number
This method is defined by EventObject.

getKey

public function getKey()
Returns a normalized keyCode for the event.
Parameters:
  • None.
Returns:
  • Number
    The key code
This method is defined by EventObject.

getPageX

public function getPageX()
Gets the x coordinate of the event.
Parameters:
  • None.
Returns:
  • Number
This method is defined by EventObject.

getPageY

public function getPageY()
Gets the y coordinate of the event.
Parameters:
  • None.
Returns:
  • Number
This method is defined by EventObject.

getRelatedTarget

public function getRelatedTarget()
Gets the related target.
Parameters:
  • None.
Returns:
  • HTMLElement
This method is defined by EventObject.

getTarget

public function getTarget( [String selector], [Number/String/HTMLElement/Element maxDepth], [Boolean returnEl] )
Gets the target for the event.
Parameters:
  • selector : String
    (optional) A simple selector to filter the target or look for an ancestor of the target
  • maxDepth : Number/String/HTMLElement/Element
    (optional) The max depth to search as a number or element (defaults to 10 || document.body)
  • returnEl : Boolean
    (optional) True to return a Ext.Element object instead of DOM node
Returns:
  • HTMLelement
This method is defined by EventObject.

getTime

public function getTime()
Gets the time of the event.
Parameters:
  • None.
Returns:
  • Number
This method is defined by EventObject.

getWheelDelta

public function getWheelDelta()
Normalizes mouse wheel delta across browsers
Parameters:
  • None.
Returns:
  • Number
    The delta
This method is defined by EventObject.

getXY

public function getXY()
Gets the page coordinates of the event.
Parameters:
  • None.
Returns:
  • Array
    The xy values like [x, y]
This method is defined by EventObject.

hasModifier

public function hasModifier()
Returns true if the control, meta, shift or alt key was pressed during this event.
Parameters:
  • None.
Returns:
  • Boolean
This method is defined by EventObject.

preventDefault

public function preventDefault()
Prevents the browsers default handling of the event.
Parameters:
  • None.
Returns:
  • void
This method is defined by EventObject.

stopEvent

public function stopEvent()
Stop the event (preventDefault and stopPropagation)
Parameters:
  • None.
Returns:
  • void
This method is defined by EventObject.

stopPropagation

public function stopPropagation()
Cancels bubbling of the event.
Parameters:
  • None.
Returns:
  • void
This method is defined by EventObject.

within

public function within( String/HTMLElement/Element el, [Boolean related] )
Returns true if the target of this event equals el or is a child of el
Parameters:
  • el : String/HTMLElement/Element
  • related : Boolean
    (optional) true to test if the related target is within el instead of the target
Returns:
  • Boolean
This method is defined by EventObject.

Ext - Copyright © 2006-2007 Ext JS, LLC
All rights reserved.