Registers event handlers that want to receive a normalized EventObject instead of the standard browser event and provides
several useful events directly.
See {link Roo.EventObject} for more details on normalized event objects.
Public Methods
|
Appends an event handler to an element (shorthand for addListener)
Appends an event handler to an element (shorthand for addListener)
- Parameters:
-
String/HTMLElement element
- The html element or id to assign the
-
String eventName
- The type of event to listen for
-
Function handler
- The method the event invokes
-
Object scope
- (optional) The scope in which to execute the handler
function. The handler function's "this" context.
-
Object options
- (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 Roo.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 {link Roo.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 });
|
Roo.EventManager
|
|
Appends an event handler to an element (shorthand for addListener)
Appends an event handler to an element (shorthand for addListener)
- Parameters:
-
String/HTMLElement element
- The html element or id to assign the
-
String eventName
- The type of event to listen for
-
Function handler
- The method the event invokes
-
Object scope
- (optional) The scope in which to execute the handler
function. The handler function's "this" context.
-
Object options
- (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 Roo.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 {link Roo.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 });
|
Roo.EventManager
|
|
Roo.EventManager.onDocumentReady
( Function fn, Object scope, boolean options)
Fires when the document is ready (before onload and before images are loaded).
Fires when the document is ready (before onload and before images are loaded). Can be accessed shorthanded Roo.onReady().
- Parameters:
-
Function fn
- The method the event invokes
-
Object scope
- An object that becomes the scope of the handler
-
boolean options
|
Roo.EventManager
|
|
Roo.EventManager.onTextResize
( Function fn, Object scope, boolean options)
Fires when the user changes the active text size.
Fires when the user changes the active text size. Handler gets called with 2 params, the old size and the new size.
- Parameters:
-
Function fn
- The method the event invokes
-
Object scope
- An object that becomes the scope of the handler
-
boolean options
|
Roo.EventManager
|
|
Roo.EventManager.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.
Fires when the window is resized and provides resize event buffering (50 milliseconds), passes new viewport width and height to handlers.
- Parameters:
-
Function fn
- The method the event invokes
-
Object scope
- An object that becomes the scope of the handler
-
boolean options
|
Roo.EventManager
|
|
Removes an event handler
Removes an event handler
- Parameters:
-
String/HTMLElement element
- The id or html element to remove the
event from
-
String eventName
- The type of event
-
Function fn
- Returns:
- Boolean True if a listener was actually removed
|
Roo.EventManager
|
|
Removes the passed window resize listener.
Removes the passed window resize listener.
- Parameters:
-
Function fn
- The method the event invokes
-
Object scope
- The scope of handler
|
Roo.EventManager
|
|
This is no longer needed and is 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 Roo.EventObject
- Parameters:
-
Function fn
- The method the event invokes
-
Object scope
- An object that becomes the scope of the handler
-
boolean override
- If true, the obj passed in becomes
the execution scope of the listener
- Returns:
- Function The wrapped function
|
Roo.EventManager
|