Print Friendly

Class Ext.EventManager

Package:Ext
Class:EventManager
Extends:Object
Defined In:EventManager.js
Registers event handlers that want to receive a normalized EventObject instead of the standard browser event and provides several useful events directly. See Ext.EventObject for more details on normalized event objects.

This class is a singleton and cannot be created directly.

Properties   -  Methods   -  Events

Public Properties

Property Defined By
  ieDeferSrc : Object EventManager
Url used for onDocumentReady with using SSL (defaults to Ext.SSL_SECURE_URL)

Public Methods

Method Defined By
  addListenerString/HTMLElement element, String eventName, Function handler, [Object scope], [Object options] ) : void EventManager
Appends an event handler to an element (shorthand for addListener)
  onDocumentReadyFunction fn, Object scope, boolean options ) : void EventManager
Fires when the document is ready (before onload and before images are loaded). Can be accessed shorthanded Ext.onRea...
  onTextResizeFunction fn, Object scope, boolean options ) : void EventManager
Fires when the user changes the active text size. Handler gets called with 2 params, the old size and the new size.
  onWindowResizeFunction fn, Object scope, boolean options ) : void EventManager
Fires when the window is resized and provides resize event buffering (50 milliseconds), passes new viewport width and...
  removeListenerString/HTMLElement element, String eventName, Function fn ) : Boolean EventManager
Removes an event handler
  removeResizeListenerFunction fn, Object scope ) : void EventManager
Removes the passed window resize listener.
  wrapFunction fn, Object scope, boolean override ) : Function EventManager
Deprecated. This is no longer needed and is deprecated. Places a simple wrapper around an event handler to override t...

Public Events

This class has no public events.

Property Details

ieDeferSrc

public Object ieDeferSrc
Url used for onDocumentReady with using SSL (defaults to Ext.SSL_SECURE_URL)
This property is defined by EventManager.

Method Details

addListener

public function addListener( String/HTMLElement element, String eventName, Function handler, [Object scope], [Object options] )
Appends an event handler to an element (shorthand for addListener)
Parameters:
  • element : String/HTMLElement
    The html element or id to assign the
  • eventName : String
    The type of event to listen for
  • handler : Function
    The method the event invokes
  • scope : Object
    (optional) The scope in which to execute the handler function. The handler function's "this" context.
  • options : Object
    (optional) An object containing handler configuration properties. This may contain any of the following properties:
    • scope {Object} The scope in which to execute the handler function. The handler function's "this" context.
    • delegate {String} A simple selector to filter the target or look for a descendant of the target
    • stopEvent {Boolean} True to stop the event. That is stop propagation, and prevent the default action.
    • preventDefault {Boolean} True to prevent the default action
    • stopPropagation {Boolean} True to prevent event propagation
    • normalized {Boolean} False to pass a browser event to the handler function instead of an Ext.EventObject
    • delay {Number} The number of milliseconds to delay the invocation of the handler after te event fires.
    • single {Boolean} True to add a handler to handle just the next firing of the event, and then remove itself.
    • buffer {Number} Causes the handler to be scheduled to run in an Ext.util.DelayedTask delayed by the specified number of milliseconds. If the event fires again within that time, the original handler is not invoked, but the new handler is scheduled in its place.

    Combining Options
    Using the options argument, it is possible to combine different types of listeners:

    A normalized, delayed, one-time listener that auto stops the event and passes a custom argument (forumId)

    Code:
    el.on('click', this.onClick, this, {
        single: true,
        delay: 100,
        stopEvent : true,
        forumId: 4
    });

    Attaching multiple handlers in 1 call
    The method also allows for a single argument to be passed which is a config object containing properties which specify multiple handlers.

    Code:

    el.on({
        'click' : {
            fn: this.onClick
            scope: this,
            delay: 100
        },
        'mouseover' : {
            fn: this.onMouseOver
            scope: this
        },
        'mouseout' : {
            fn: this.onMouseOut
            scope: this
        }
    });

    Or a shorthand syntax:
    Code:

    el.on({
        'click' : this.onClick,
        'mouseover' : this.onMouseOver,
        'mouseout' : this.onMouseOut
        scope: this
    });
Returns:
  • void
This method is defined by EventManager.

onDocumentReady

public function onDocumentReady( Function fn, Object scope, boolean options )
Fires when the document is ready (before onload and before images are loaded). Can be accessed shorthanded Ext.onReady().
Parameters:
  • fn : Function
    The method the event invokes
  • scope : Object
    An object that becomes the scope of the handler
  • options : boolean
Returns:
  • void
This method is defined by EventManager.

onTextResize

public function onTextResize( Function fn, Object scope, boolean options )
Fires when the user changes the active text size. Handler gets called with 2 params, the old size and the new size.
Parameters:
  • fn : Function
    The method the event invokes
  • scope : Object
    An object that becomes the scope of the handler
  • options : boolean
Returns:
  • void
This method is defined by EventManager.

onWindowResize

public function onWindowResize( Function fn, Object scope, boolean options )
Fires when the window is resized and provides resize event buffering (50 milliseconds), passes new viewport width and height to handlers.
Parameters:
  • fn : Function
    The method the event invokes
  • scope : Object
    An object that becomes the scope of the handler
  • options : boolean
Returns:
  • void
This method is defined by EventManager.

removeListener

public function removeListener( String/HTMLElement element, String eventName, Function fn )
Removes an event handler
Parameters:
  • element : String/HTMLElement
    The id or html element to remove the event from
  • eventName : String
    The type of event
  • fn : Function
Returns:
  • Boolean
    True if a listener was actually removed
This method is defined by EventManager.

removeResizeListener

public function removeResizeListener( Function fn, Object scope )
Removes the passed window resize listener.
Parameters:
  • fn : Function
    The method the event invokes
  • scope : Object
    The scope of handler
Returns:
  • void
This method is defined by EventManager.

wrap

public function wrap( Function fn, Object scope, boolean override )
Deprecated. This is no longer needed and is deprecated. Places a simple wrapper around an event handler to override the browser event object with a Ext.EventObject
Parameters:
  • fn : Function
    The method the event invokes
  • scope : Object
    An object that becomes the scope of the handler
  • override : boolean
    If true, the obj passed in becomes the execution scope of the listener
Returns:
  • Function
    The wrapped function
This method is defined by EventManager.

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