events.EventHandler Extends goog.Disposable
Super class for objects that want to easily manage a number of event listeners. It allows a short cut to listen and also provides a quick way to remove all events listeners belonging to this object. It is optimized to use less objects if only one event is being listened to, but if that's the case, it may not be worth using the EventHandler anyway.

Inheritance

Object
     goog.Disposable
          goog.events.EventHandler

Constructor

goog.events.EventHandler(opt_handler)

Parameters

opt_handler :
Object in whose scope to call the listeners.

Instance Methods

Public Protected Private
disposeInternal()
No description.
code »
handleEvent(e)
Default event handler
Arguments:
e :
Event object.
code »
listen(srctypeopt_fnopt_captureopt_handler)
Listen to an event on a DOM node or EventTarget. If the function is ommitted then the EventHandler's handleEvent method will be used.
Arguments:
src :
goog.events.EventTarget | EventTarget
Event source.
type :
Event type to listen for or array of event types.
opt_fn :
Optional callback function to be used as the listener or an object with handleEvent function.
opt_capture :
Optional whether to use capture phase.
opt_handler :
Object in whose scope to call the listener.
Returns:   This object, allowing for chaining of calls.
code »
listenOnce(srctypeopt_fnopt_captureopt_handler)
Listen to an event on a DOM node or EventTarget. If the function is ommitted then the EventHandler's handleEvent method will be used. After the event has fired the event listener is removed from the target. If an array of event types is provided, each event type will be listened to once.
Arguments:
src :
goog.events.EventTarget | EventTarget
Event source.
type :
Event type to listen for or array of event types.
opt_fn :
Optional callback function to be used as the listener or an object with handleEvent function.
opt_capture :
Optional whether to use capture phase.
opt_handler :
Object in whose scope to call the listener.
Returns:   This object, allowing for chaining of calls.
code »
listenWithWrapper(srcwrapperlisteneropt_captopt_handler)
Adds an event listener with a specific event wrapper on a DOM Node or an object that has implemented {@link goog.events.EventTarget}. A listener can only be added once to an object.
Arguments:
src :
EventTarget | goog.events.EventTarget
The node to listen to events on.
wrapper :
goog.events.EventWrapper
Event wrapper to use.
listener :
Callback method, or an object with a handleEvent function.
opt_capt :
Whether to fire in capture phase (defaults to false).
opt_handler :
Element in whose scope to call the listener.
Returns:   This object, allowing for chaining of calls.
code »
recordListenerKey_(key)
Record the key returned for the listener so that it can be user later to remove the listener.
Arguments:
key :
Unique key for the listener.
code »
removeAll()
No description.
code »
unlisten(srctypeopt_fnopt_captureopt_handler)
Unlistens on an event.
Arguments:
src :
goog.events.EventTarget | EventTarget
Event source.
type :
Event type to listen for.
opt_fn :
Optional callback function to be used as the listener or an object with handleEvent function.
opt_capture :
Optional whether to use capture phase.
opt_handler :
Object in whose scope to call the listener.
Returns:   This object, allowing for chaining of calls.
code »
unlistenWithWrapper(srcwrapperlisteneropt_captopt_handler)
Removes an event listener which was added with listenWithWrapper().
Arguments:
src :
EventTarget | goog.events.EventTarget
The target to stop listening to events on.
wrapper :
goog.events.EventWrapper
Event wrapper to use.
listener :
The listener function to remove.
opt_capt :
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_handler :
Element in whose scope to call the listener.
Returns:   This object, allowing for chaining of calls.
code »
dispose()
No description.
code »
disposeInternal()
Deletes or nulls out any references to COM objects, DOM nodes, or other disposable objects. Classes that extend {@code goog.Disposable} should override this method. For example:
mypackage.MyClass = function() {
goog.Disposable.call(this);
// Constructor logic specific to MyClass.
...
};
goog.inherits(mypackage.MyClass, goog.Disposable);

mypackage.MyClass.prototype.disposeInternal = function() {
mypackage.MyClass.superClass_.disposeInternal.call(this);
// Dispose logic specific to MyClass.
...
};
code »
getDisposed()
No description.
Returns:   Whether the object has been disposed of.
code »
isDisposed()
No description.
Returns:   Whether the object has been disposed of.
code »

Instance Properties

disposed_ :
Whether the object has been disposed of.
Code »

Static Properties

goog.events.EventHandler.KEY_POOL_INITIAL_COUNT :
Initial count for the keyPool_
Code »
goog.events.EventHandler.KEY_POOL_MAX_COUNT :
Max count for the keyPool_
Code »
goog.events.EventHandler.keyPool_ :
SimplePool to cache the key object. This was implemented to make IE6 performance better and removed an object allocation in the listen method when in steady state.
Code »
goog.events.EventHandler.key_ :
Keys for event that is being listened to if only one event is being listened to. This is a performance optimization to avoid creating an extra object if not necessary.
Code »
goog.events.EventHandler.keys_ :
Keys for events that are being listened to. This is used once there are more than one event to listen to. If there is only one event to listen to, key_ is used.
Code »

Package events

Package Reference