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.
|
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. |
|
within(String/HTMLElement/Element el , [Boolean related ]) : Boolean |
EventObject |
Returns true if the target of this event equals el or is a child of el |
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.
getCharCode
public function getCharCode()
Gets the key code for the event.
This method is defined by EventObject.
getKey
public function getKey()
Returns a normalized keyCode for the event.
This method is defined by EventObject.
getPageX
public function getPageX()
Gets the x coordinate of the event.
This method is defined by EventObject.
getPageY
public function getPageY()
Gets the y coordinate of the event.
This method is defined by EventObject.
getRelatedTarget
public function getRelatedTarget()
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.
参数:
selector
: String(可选) A simple selector to filter the target or look for an ancestor of the target
maxDepth
: Number/String/HTMLElement/Element(可选) The max depth to search as a number or element (defaults to 10 || document.body)
returnEl
: Boolean(可选) True to return a Ext.Element object instead of DOM node
返回:
This method is defined by EventObject.
getTime
public function getTime()
Gets the time of the event.
This method is defined by EventObject.
getWheelDelta
public function getWheelDelta()
Normalizes mouse wheel delta across browsers
This method is defined by EventObject.
getXY
public function getXY()
Gets the page coordinates of the event.
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.
This method is defined by EventObject.
preventDefault
public function preventDefault()
Prevents the browsers default handling of the event.
This method is defined by EventObject.
stopEvent
public function stopEvent()
Stop the event (preventDefault and stopPropagation)
This method is defined by EventObject.
stopPropagation
public function stopPropagation()
Cancels bubbling of the event.
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
This method is defined by EventObject.