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.

Inheritance

Constructor

goog.events.EventHandler(opt_scope)

Parameters

opt_scope : SCOPE=
Object in whose scope to call the listeners.

Instance Methods

Public Protected Private
disposeInternal()
Disposes of this EventHandler and removes all listeners that it registered.
code »
getListenerCount() number
No description.
Returns: number  Number of listeners registered by this handler.
code »
handleEvent(e)
Default event handler
Arguments:
e : goog.events.Event
Event object.
code »
listen(srctypeopt_capture) !goog.events.EventHandler.<SCOPE>
Listen to an event on a Listenable. If the function is omitted then the EventHandler's handleEvent method will be used.
Arguments:
src : goog.events.ListenableType
Event source.
type : string | Array.<string> |  !goog.events.EventId.<EVENTOBJ> | !Array.<!goog.events.EventId.<EVENTOBJ>>
Event type to listen for or array of event types.
: function(this:SCOPE, EVENTOBJ):? | ?{handleEvent:function():?
No description.
opt_capture : boolean=
Optional whether to use capture phase.
Returns: !goog.events.EventHandler.<SCOPE>  This object, allowing for chaining of calls.
code »
listenOnce(srctypeopt_capture) !goog.events.EventHandler.<SCOPE>
Listen to an event on a Listenable. If the function is omitted, 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.ListenableType
Event source.
type : string | Array.<string> |  !goog.events.EventId.<EVENTOBJ> | !Array.<!goog.events.EventId.<EVENTOBJ>>
Event type to listen for or array of event types.
: function(this:SCOPE, EVENTOBJ):? | ?{handleEvent:function():?
No description.
opt_capture : boolean=
Optional whether to use capture phase.
Returns: !goog.events.EventHandler.<SCOPE>  This object, allowing for chaining of calls.
code »
listenOnceWithScope(srctypecapturescope) !goog.events.EventHandler.<SCOPE>
Listen to an event on a Listenable. If the function is omitted, 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.ListenableType
Event source.
type : string | Array.<string> |  !goog.events.EventId.<EVENTOBJ> | !Array.<!goog.events.EventId.<EVENTOBJ>>
Event type to listen for or array of event types.
: function(this:T, EVENTOBJ):? | ?{handleEvent:function(this:T, ):?
No description.
capture : boolean | undefined
Optional whether to use capture phase.
scope : T
Object in whose scope to call the listener.
Returns: !goog.events.EventHandler.<SCOPE>  This object, allowing for chaining of calls.
code »
listenOnce_(srctypeopt_captureopt_scope) !goog.events.EventHandler.<SCOPE>
Listen to an event on a Listenable. If the function is omitted, 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.ListenableType
Event source.
type : string | Array.<string> |  !goog.events.EventId.<EVENTOBJ> | !Array.<!goog.events.EventId.<EVENTOBJ>>
Event type to listen for or array of event types.
: function(EVENTOBJ):? | ?{handleEvent:function():?
No description.
opt_capture : boolean=
Optional whether to use capture phase.
opt_scope : Object=
Object in whose scope to call the listener.
Returns: !goog.events.EventHandler.<SCOPE>  This object, allowing for chaining of calls.
code »
listenWithScope(srctypecapturescope) !goog.events.EventHandler.<SCOPE>
Listen to an event on a Listenable. If the function is omitted then the EventHandler's handleEvent method will be used.
Arguments:
src : goog.events.ListenableType
Event source.
type : string | Array.<string> |  !goog.events.EventId.<EVENTOBJ> | !Array.<!goog.events.EventId.<EVENTOBJ>>
Event type to listen for or array of event types.
: function(this:T, EVENTOBJ):? | ?{handleEvent:function(this:T, ):?
No description.
capture : boolean | undefined
Optional whether to use capture phase.
scope : T
Object in whose scope to call the listener.
Returns: !goog.events.EventHandler.<SCOPE>  This object, allowing for chaining of calls.
code »
listenWithWrapper(srcwrapperopt_capt) !goog.events.EventHandler.<SCOPE>
Adds an event listener with a specific event wrapper on a DOM Node or an object that has implemented 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.
: ?function(this:SCOPE, ):? | ?{handleEvent:function():?
No description.
opt_capt : boolean=
Whether to fire in capture phase (defaults to false).
Returns: !goog.events.EventHandler.<SCOPE>  This object, allowing for chaining of calls.
code »
listenWithWrapperAndScope(srcwrappercapturescope) !goog.events.EventHandler.<SCOPE>
Adds an event listener with a specific event wrapper on a DOM Node or an object that has implemented 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.
: ?function(this:T, ):? | ?{handleEvent:function(this:T, ):?
No description.
capture : boolean | undefined
Optional whether to use capture phase.
scope : T
Object in whose scope to call the listener.
Returns: !goog.events.EventHandler.<SCOPE>  This object, allowing for chaining of calls.
code »
listenWithWrapper_(srcwrapperopt_captopt_scope) !goog.events.EventHandler.<SCOPE>
Adds an event listener with a specific event wrapper on a DOM Node or an object that has implemented 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.
: ?function():? | ?{handleEvent:function():?
No description.
opt_capt : boolean=
Whether to fire in capture phase (defaults to false).
opt_scope : Object=
Element in whose scope to call the listener.
Returns: !goog.events.EventHandler.<SCOPE>  This object, allowing for chaining of calls.
code »
listen_(srctypeopt_captureopt_scope) !goog.events.EventHandler.<SCOPE>
Listen to an event on a Listenable. If the function is omitted then the EventHandler's handleEvent method will be used.
Arguments:
src : goog.events.ListenableType
Event source.
type : string | Array.<string> |  !goog.events.EventId.<EVENTOBJ> | !Array.<!goog.events.EventId.<EVENTOBJ>>
Event type to listen for or array of event types.
: function(EVENTOBJ):? | ?{handleEvent:function():?
No description.
opt_capture : boolean=
Optional whether to use capture phase.
opt_scope : Object=
Object in whose scope to call the listener.
Returns: !goog.events.EventHandler.<SCOPE>  This object, allowing for chaining of calls.
code »
removeAll()
Unlistens to all events.
code »
unlisten(srctypeopt_captureopt_scope) !goog.events.EventHandler
Unlistens on an event.
Arguments:
src : goog.events.ListenableType
Event source.
type : string | Array.<string> |  !goog.events.EventId.<EVENTOBJ> | !Array.<!goog.events.EventId.<EVENTOBJ>>
Event type or array of event types to unlisten to.
: function(EVENTOBJ):? | ?{handleEvent:function():?
No description.
opt_capture : boolean=
Optional whether to use capture phase.
opt_scope : Object=
Object in whose scope to call the listener.
Returns: !goog.events.EventHandler  This object, allowing for chaining of calls.
code »
unlistenWithWrapper(srcwrapperopt_captopt_scope) !goog.events.EventHandler
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.
: ?function():? | ?{handleEvent:function():?
No description.
opt_capt : boolean=
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_scope : Object=
Element in whose scope to call the listener.
Returns: !goog.events.EventHandler  This object, allowing for chaining of calls.
code »
addOnDisposeCallback(callbackopt_scope)
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.
Arguments:
callback : function(this:T):?
The callback function.
opt_scope : T=
An optional scope to call the callback in.
code »
dispose() void
Disposes of the object. If the object hasn't already been disposed of, calls #disposeInternal. Classes that extend goog.Disposable should override #disposeInternal in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.
Returns: void  Nothing.
code »
disposeInternal()
Deletes or nulls out any references to COM objects, DOM nodes, or other disposable objects. Classes that extend goog.Disposable should override this method. Not reentrant. To avoid calling it twice, it must only be called from the subclass' disposeInternal method. Everywhere else the public dispose method must be used. For example:
  mypackage.MyClass = function() {
    mypackage.MyClass.base(this, 'constructor');
    // Constructor logic specific to MyClass.
    ...
  };
  goog.inherits(mypackage.MyClass, goog.Disposable);

  mypackage.MyClass.prototype.disposeInternal = function() {
    // Dispose logic specific to MyClass.
    ...
    // Call superclass's disposeInternal at the end of the subclass's, like
    // in C++, to avoid hard-to-catch issues.
    mypackage.MyClass.base(this, 'disposeInternal');
  };
code »
getDisposed() boolean
Use #isDisposed instead. No description.
Returns: boolean  Whether the object has been disposed of.
code »
isDisposed() boolean
No description.
Returns: boolean  Whether the object has been disposed of.
code »
registerDisposable(disposable)
Associates a disposable object with this object so that they will be disposed together.
Arguments:
disposable : goog.disposable.IDisposable
that will be disposed when this object is disposed.
code »

Instance Properties

constructor :
No description.
Code »
handler_ :
No description.
Code »
keys_ :
Keys for events that are being listened to.
Code »
creationStack :
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
Code »
disposed_ :
Whether the object has been disposed of.
Code »
onDisposeCallbacks_ :
Callbacks to invoke when this object is disposed.
Code »

Static Properties

goog.events.EventHandler.superClass_ :
No description.
Code »
goog.events.EventHandler.typeArray_ :
Utility array used to unify the cases of listening for an array of types and listening for a single event, without using recursion or allocating an array each time.
Code »

Package events

Package Reference