For up to date documentation and features, visit http://docs.sencha.com/ext-js/4-0

## Sencha Documentation

# Ext.EventObject

Just as Ext.core.Element wraps around a native DOM node, Ext.EventObject wraps the browser's native event-object normalizing cross-browser differences, such as which mouse button is clicked, keys pressed, mechanisms to stop event-propagation along with a method to prevent default actions from taking place.

For example:

    function handleClick(e, t){ // e is not a standard event object, it is a Ext.EventObject
        e.preventDefault();
        var target = e.getTarget(); // same as t (the target HTMLElement)
        ...
    }

    var myDiv = Ext.get("myDiv");  // get reference to an Ext.core.Element
    myDiv.on(         // 'on' is shorthand for addListener
        "click",      // perform an action on click of myDiv
        handleClick   // reference to the action handler
    );

    // other methods to do the same:
    Ext.EventManager.on("myDiv", 'click', handleClick);
    Ext.EventManager.addListener("myDiv", 'click', handleClick);

Defined By

### Properties

Ext.EventObject
view source
A : Number

Key constant

Key constant

Ext.EventObject
view source
ALT : Number

Key constant

Key constant

Ext.EventObject
view source
B : Number

Key constant

Key constant

Ext.EventObject
view source
BACKSPACE : Number

Key constant

Key constant

Ext.EventObject
view source
C : Number

Key constant

Key constant

Ext.EventObject
view source
CAPS_LOCK : Number

Key constant

Key constant

Ext.EventObject
view source
CTRL : Number

Key constant

Key constant

Ext.EventObject
view source
D : Number

Key constant

Key constant

Ext.EventObject
view source
DELETE : Number

Key constant

Key constant

Ext.EventObject
view source
DOWN : Number

Key constant

Key constant

Ext.EventObject
view source
E : Number

Key constant

Key constant

Ext.EventObject
view source
EIGHT : Number

Key constant

Key constant

Ext.EventObject
view source
END : Number

Key constant

Key constant

Ext.EventObject
view source
ENTER : Number

Key constant

Key constant

Ext.EventObject
view source
ESC : Number

Key constant

Key constant

Ext.EventObject
view source
F : Number

Key constant

Key constant

Ext.EventObject
view source
F1 : Number

Key constant

Key constant

Ext.EventObject
view source
F10 : Number

Key constant

Key constant

Ext.EventObject
view source
F11 : Number

Key constant

Key constant

Ext.EventObject
view source
F12 : Number

Key constant

Key constant

Ext.EventObject
view source
F2 : Number

Key constant

Key constant

Ext.EventObject
view source
F3 : Number

Key constant

Key constant

Ext.EventObject
view source
F4 : Number

Key constant

Key constant

Ext.EventObject
view source
F5 : Number

Key constant

Key constant

Ext.EventObject
view source
F6 : Number

Key constant

Key constant

Ext.EventObject
view source
F7 : Number

Key constant

Key constant

Ext.EventObject
view source
F8 : Number

Key constant

Key constant

Ext.EventObject
view source
F9 : Number

Key constant

Key constant

Ext.EventObject
view source
FIVE : Number

Key constant

Key constant

Ext.EventObject
view source
FOUR : Number

Key constant

Key constant

Ext.EventObject
view source
G : Number

Key constant

Key constant

Ext.EventObject
view source
H : Number

Key constant

Key constant

Ext.EventObject
view source
HOME : Number

Key constant

Key constant

Ext.EventObject
view source
I : Number

Key constant

Key constant

Ext.EventObject
view source
INSERT : Number

Key constant

Key constant

Ext.EventObject
view source
J : Number

Key constant

Key constant

Ext.EventObject
view source
K : Number

Key constant

Key constant

Ext.EventObject
view source
L : Number

Key constant

Key constant

Ext.EventObject
view source
LEFT : Number

Key constant

Key constant

Ext.EventObject
view source
M : Number

Key constant

Key constant

Ext.EventObject
view source
N : Number

Key constant

Key constant

Ext.EventObject
view source
NINE : Number

Key constant

Key constant

Ext.EventObject
view source
NUM_CENTER : Number

Key constant

Key constant

Ext.EventObject
view source
NUM_DIVISION : Number

Key constant

Key constant

Ext.EventObject
view source
NUM_EIGHT : Number

Key constant

Key constant

Ext.EventObject
view source
NUM_FIVE : Number

Key constant

Key constant

Ext.EventObject
view source
NUM_FOUR : Number

Key constant

Key constant

Ext.EventObject
view source
NUM_MINUS : Number

Key constant

Key constant

Ext.EventObject
view source
NUM_MULTIPLY : Number

Key constant

Key constant

Ext.EventObject
view source
NUM_NINE : Number

Key constant

Key constant

Ext.EventObject
view source
NUM_ONE : Number

Key constant

Key constant

Ext.EventObject
view source
NUM_PERIOD : Number

Key constant

Key constant

Ext.EventObject
view source
NUM_PLUS : Number

Key constant

Key constant

Ext.EventObject
view source
NUM_SEVEN : Number

Key constant

Key constant

Ext.EventObject
view source
NUM_SIX : Number

Key constant

Key constant

Ext.EventObject
view source
NUM_THREE : Number

Key constant

Key constant

Ext.EventObject
view source
NUM_TWO : Number

Key constant

Key constant

Ext.EventObject
view source
NUM_ZERO : Number

Key constant

Key constant

Ext.EventObject
view source
O : Number

Key constant

Key constant

Ext.EventObject
view source
ONE : Number

Key constant

Key constant

Ext.EventObject
view source
P : Number

Key constant

Key constant

Ext.EventObject
view source
PAGE_DOWN : Number

Key constant

Key constant

Ext.EventObject
view source
PAGE_UP : Number

Key constant

Key constant

Ext.EventObject
view source
PAUSE : Number

Key constant

Key constant

Ext.EventObject
view source
PRINT_SCREEN : Number

Key constant

Key constant

Ext.EventObject
view source
Q : Number

Key constant

Key constant

Ext.EventObject
view source
R : Number

Key constant

Key constant

Ext.EventObject
view source
RETURN : Number

Key constant

Key constant

Ext.EventObject
view source
RIGHT : Number

Key constant

Key constant

Ext.EventObject
view source
S : Number

Key constant

Key constant

Ext.EventObject
view source
SEVEN : Number

Key constant

Key constant

Ext.EventObject
view source
SHIFT : Number

Key constant

Key constant

Ext.EventObject
view source
SIX : Number

Key constant

Key constant

Ext.EventObject
view source
SPACE : Number

Key constant

Key constant

Ext.EventObject
view source
T : Number

Key constant

Key constant

Ext.EventObject
view source
TAB : Number

Key constant

Key constant

Ext.EventObject
view source
THREE : Number

Key constant

Key constant

Ext.EventObject
view source
TWO : Number

Key constant

Key constant

Ext.EventObject
view source
U : Number

Key constant

Key constant

Ext.EventObject
view source
UP : Number

Key constant

Key constant

Ext.EventObject
view source
V : Number

Key constant

Key constant

Ext.EventObject
view source
W : Number

Key constant

Key constant

Ext.EventObject
view source
X : Number

Key constant

Key constant

Ext.EventObject
view source
Y : Number

Key constant

Key constant

Ext.EventObject
view source
Z : Number

Key constant

Key constant

Ext.EventObject
view source
ZERO : Number

Key constant

Key constant

Defined By

### Methods

Ext.EventObject
view source
getCharCode : Number

Gets the character code for the event.

Gets the character code for the event.

### Returns

- Number

Ext.EventObject
view source
getKey : Number

Returns a normalized keyCode for the event.

Returns a normalized keyCode for the event.

### Returns

- Number

  The key code

Ext.EventObject
view source
getPageX : Number

Gets the x coordinate of the event.

Gets the x coordinate of the event.

### Returns

- Number

  @deprecated 4.0 Replaced by getX

Ext.EventObject
view source
getPageY : Number

Gets the y coordinate of the event.

Gets the y coordinate of the event.

### Returns

- Number

  @deprecated 4.0 Replaced by getY

Ext.EventObject
view source
getPoint : Ext.util.Point

Returns a point object that consists of the object coordinates.

Returns a point object that consists of the object coordinates.

### Returns

- Ext.util.Point

  point

Ext.EventObject
view source
getRelatedTarget( [String selector], [Number/Mixed maxDepth], [Boolean returnEl]) : HTMLElement

Gets the related target.

Gets the related target.

### Parameters

- selector : String

  (optional) A simple selector to filter the target or look for an ancestor of the target

- maxDepth : Number/Mixed

  (optional) The max depth to search as a number or element (defaults to 10 || document.body)

- returnEl : Boolean

  (optional) True to return a Ext.core.Element object instead of DOM node

### Returns

- HTMLElement

Ext.EventObject
view source
getTarget( [String selector], [Number/Mixed maxDepth], [Boolean returnEl]) : HTMLelement

Gets the target for the event.

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/Mixed

  (optional) The max depth to search as a number or element (defaults to 10 || document.body)

- returnEl : Boolean

  (optional) True to return a Ext.core.Element object instead of DOM node

### Returns

- HTMLelement

Ext.EventObject
view source
getWheelDelta : Number

Normalizes mouse wheel delta across browsers

Normalizes mouse wheel delta across browsers

### Returns

- Number

  The delta

Ext.EventObject
view source
getX : Number

Gets the x coordinate of the event.

Gets the x coordinate of the event.

### Returns

- Number

Ext.EventObject
view source
getXY : Array

Gets the page coordinates of the event.

Gets the page coordinates of the event.

### Returns

- Array

  The xy values like [x, y]

Ext.EventObject
view source
getY : Number

Gets the y coordinate of the event.

Gets the y coordinate of the event.

### Returns

- Number

Ext.EventObject
view source
hasModifier : Boolean

Returns true if the control, meta, shift or alt key was pressed during this event.

Returns true if the control, meta, shift or alt key was pressed during this event.

### Returns

- Boolean

Ext.EventObject
view source
injectEvent( Element/HTMLElement target) : void
Injects a DOM event using the data in this object and (optionally) a new target. This is a low-level technique and no...

Injects a DOM event using the data in this object and (optionally) a new target. This is a low-level technique and not likely to be used by application code. The currently supported event types are:

HTMLEvents

- load
- unload
- select
- change
- submit
- reset
- resize
- scroll

MouseEvents

- click
- dblclick
- mousedown
- mouseup
- mouseover
- mousemove
- mouseout

UIEvents

- focusin
- focusout
- activate
- focus
- blur

### Parameters

- target : Element/HTMLElement

  If specified, the target for the event. This is likely to be used when relaying a DOM event. If not specified, getTarget is used to determine the target.

### Returns

- void

Ext.EventObject
view source
isNavKeyPress : Boolean

Checks if the key pressed was a "navigation" key

Checks if the key pressed was a "navigation" key

### Returns

- Boolean

  True if the press is a navigation keypress

Ext.EventObject
view source
isSpecialKey : Boolean

Checks if the key pressed was a "special" key

Checks if the key pressed was a "special" key

### Returns

- Boolean

  True if the press is a special keypress

Ext.EventObject
view source
preventDefault : void

Prevents the browsers default handling of the event.

Prevents the browsers default handling of the event.

### Returns

- void

Ext.EventObject
view source
stopEvent : void

Stop the event (preventDefault and stopPropagation)

Stop the event (preventDefault and stopPropagation)

### Returns

- void

Ext.EventObject
view source
stopPropagation : void

Cancels bubbling of the event.

Cancels bubbling of the event.

### Returns

- void

Ext.EventObject
view source
within( Mixed el, [Boolean related], Boolean allowEl) : Boolean
Returns true if the target of this event is a child of el. Unless the allowEl parameter is set, it will return false...

Returns true if the target of this event is a child of el. Unless the allowEl parameter is set, it will return false if if the target is el. Example usage:

    // Handle click on any child of an element
    Ext.getBody().on('click', function(e){
        if(e.within('some-el')){
            alert('Clicked on a child of some-el!');
        }
    });

    // Handle click directly on an element, ignoring clicks on child nodes
    Ext.getBody().on('click', function(e,t){
        if((t.id == 'some-el') && !e.within(t, true)){
            alert('Clicked directly on some-el!');
        }
    });

### Parameters

- el : Mixed

  The id, DOM element or Ext.core.Element to check

- related : Boolean

  (optional) true to test if the related target is within el instead of the target

- allowEl : Boolean

  {optional} true to also check if the passed element is the target or related target

### Returns

- Boolean