/** @type {goog.events.EventId.}
var myEventId = new goog.events.EventId(
goog.events.getUniqueId(('someEvent'));
// No need to cast or declare here since the compiler knows the correct
// type of 'evt' (MyEventObj).
something.listen(myEventId, function(evt) {});
goog.events.Listenable
with full W3C
EventTarget-like support (capture/bubble mechanism, stopping event
propagation, preventing default actions).
You may subclass this class to turn your class into a Listenable.
Unless propagation is stopped, an event dispatched by an
EventTarget will bubble to the parent returned by
getParentEventTarget
. To set the parent, call
setParentEventTarget
. Subclasses that don't support
changing the parent can override the setter to throw an error.
Example usage:
var source = new goog.events.EventTarget(); function handleEvent(e) { alert('Type: ' + e.type + '; Target: ' + e.target); } source.listen('foo', handleEvent); // Or: goog.events.listen(source, 'foo', handleEvent); ... source.dispatchEvent('foo'); // will call handleEvent ... source.unlisten('foo', handleEvent); // Or: goog.events.unlisten(source, 'foo', handleEvent);
element
as parameter
and fires goog.events.FileDropHandler.EventType.DROP
event when files
are dropped in the element
.
#getParentEventTarget
; this tree
must be directed acyclic graph. The meaning of default action(s)
in preventDefault is specific to a particular use case.
Implementations that do not support capture/bubble or can not have
a parent listenable can simply not implement any ability to set the
parent listenable (and have #getParentEventTarget
return
null).
Implementation of this class can be used with or independently from
goog.events.
Implementation must call #addImplementation(implClass)
.
element
as parameter and fires
goog.events.PasteHandler.EventType.PASTE
events when text is
pasted in the element
. Uses heuristics to detect paste events in FF2.
See more details of the heuristic on #handleEvent_
.
![]()
Enum of browser capabilities.
Constants:
|
Code » | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]()
No description.
Constants:
|
Code » | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]()
Constants for event names.
Constants:
|
Code » | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]()
Key codes for common characters.
This list is not localized and therefore some of the key codes are not
correct for non US keyboard layouts. See comments below.
Constants:
|
Code » | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]()
Key names for common characters. These should be used with keyup/keydown
events, since the .keyCode property on those is meant to indicate the
*physical key* the user held down on the keyboard. Hence the mapping uses
only the unshifted version of each key (e.g. no '#', since that's shift+3).
Keypress events on the other hand generate (mostly) ASCII codes since they
correspond to *characters* the user typed.
For further reference: http://unixpapa.com/js/key.html
This list is not localized and therefore some of the key codes are not
correct for non-US keyboard layouts.
Constants:
|
Code » |
Dispatches an event (or event like object) and calls all listeners
listening for events of this type. The type of the event is decided by the
type property on the event object.
If any of the listeners returns false OR calls preventDefault then this
function will return false. If one of the capture listeners calls
stopPropagation, then the bubble listeners won't fire.
Arguments:
Returns: boolean
If anyone called preventDefault on the event object (or
if any of the handlers returns false) this will also return false.
If there are no handlers, or if all handlers return true, this returns
true.
|
code » | |||||||
Provides a nice string showing the normalized event objects public members
|
code » | |||||||
Fires a listener with a set of arguments
Arguments:
Returns: boolean
Result of listener.
|
code » | |||||||
Fires an object's listeners of a particular type and phase
|
code » | |||||||
Fires an object's listeners of a particular type and phase.
|
code » | |||||||
Gets the goog.events.Listener for the event or null if no such listener is
in use.
Arguments:
Returns: goog.events.ListenableKey
the found listener or null if not found.
|
code » | |||||||
No description.
Arguments:
Returns: goog.events.ListenerMap
A listener map for the given
source object, or null if none exists.
|
code » | |||||||
Gets the listeners for a given object, type and capture phase.
Arguments:
Returns: Array.<goog.events.Listener>
Array of listener objects.
|
code » | |||||||
Returns a string with on prepended to the specified type. This is used for IE
which expects "on" to be prepended. This function caches the string in order
to avoid extra allocations in steady state.
|
code » | |||||||
Helper function for returning a proxy function.
Returns: !Function
A new or reused function object.
|
code » | |||||||
This returns estimated count, now that Closure no longer
stores a central listener registry. We still return an estimation
to keep existing listener-related tests passing. In the near future,
this function will be removed.
Gets the total number of listeners currently in the system.
Returns: number
Number of listeners.
|
code » | |||||||
Creates a unique event id.
|
code » | |||||||
Returns a prefixed event name for the current browser.
|
code » | |||||||
Handles an event and dispatches it to the correct listeners. This
function is a proxy for the real listener the user specified.
Arguments:
Returns: boolean
Result of the event handler.
|
code » | |||||||
![]()
No description.
|
code » | |||||||
Returns whether an event target has any active listeners matching the
specified signature. If either the type or capture parameters are
unspecified, the function will match on the remaining criteria.
Arguments:
Returns: boolean
Whether an event target has one or more listeners matching
the requested type and/or capture phase.
|
code » | |||||||
This is used to check if an IE event has already been handled by the Closure
system so we do not do the Closure pass twice for a bubbling event.
Arguments:
Returns: boolean
True if the event object has been marked.
|
code » | |||||||
![]()
Adds an event listener for a specific event on a native event
target (such as a DOM element) or an object that has implemented
goog.events.Listenable . A listener can only be added once
to an object and if it is added again the key for the listener is
returned. Note that if the existing listener is a one-off listener
(registered via listenOnce), it will no longer be a one-off
listener after a call to listen().
Arguments:
Returns: goog.events.Key
Unique key for the listener.
|
code » | |||||||
![]()
Adds an event listener for a specific event on a native event
target (such as a DOM element) or an object that has implemented
goog.events.Listenable . After the event has fired the event
listener is removed from the target.
If an existing listener already exists, listenOnce will do
nothing. In particular, if the listener was previously registered
via listen(), listenOnce() will not turn the listener into a
one-off listener. Similarly, if there is already an existing
one-off listener, listenOnce does not modify the listeners (it is
still a once listener).
Arguments:
Returns: goog.events.Key
Unique key for the listener.
|
code » | |||||||
![]()
Adds an event listener with a specific event wrapper on a DOM Node or an
object that has implemented
goog.events.Listenable . A listener can
only be added once to an object.
Arguments:
|
code » | |||||||
![]()
Adds an event listener for a specific event on a native event
target. A listener can only be added once to an object and if it
is added again the key for the listener is returned.
Note that a one-off listener will not change an existing listener,
if any. On the other hand a normal listener will change existing
one-off listener to become a normal listener.
Arguments:
Returns: goog.events.ListenableKey
Unique key for the listener.
|
code » | |||||||
![]()
This is used to mark the IE event object so we do not do the Closure pass
twice for a bubbling event.
Arguments:
|
code » | |||||||
![]()
Installs exception protection for the browser event entry point using the
given error handler.
Arguments:
|
code » | |||||||
Removes all listeners from an object. You can also optionally
remove listeners of a particular type.
|
code » | |||||||
This doesn't do anything, now that Closure no longer
stores a central listener registry.
Removes all native listeners registered via goog.events. Native
listeners are listeners on native browser objects (such as DOM
elements). In particular, goog.events.Listenable and
goog.events.EventTarget listeners will NOT be removed.
Returns: number
Number of listeners removed.
|
code » | |||||||
Removes an event listener which was added with listen().
Arguments:
Returns: ?boolean
indicating whether the listener was there to remove.
|
code » | |||||||
Removes an event listener which was added with listen() by the key
returned by listen().
Arguments:
Returns: boolean
indicating whether the listener was there to remove.
|
code » | |||||||
![]()
Removes an event listener which was added with listenWithWrapper().
Arguments:
|
code » | |||||||
No description.
Arguments:
Returns: !Function
Either the original function or a function that
calls obj.handleEvent. If the same listener is passed to this
function more than once, the same function is guaranteed to be
returned.
|
code » |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
A typedef for event like objects that are dispatchable via the
goog.events.dispatchEvent function. strings are treated as the type for a
goog.events.Event. Objects are treated as an extension of a new
goog.events.Event with the type property of the object being used as the type
of the Event.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
Property name on a native event target for the listener map
associated with the event target.
|
Code » | |
![]()
Expando property for listener function wrapper for Object with
handleEvent.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
Singleton instance of ActionEventWrapper_.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
Estimated count of total native listeners.
|
Code » | |
![]()
Container for storing event listeners and their proxies
TODO(user): Remove this when all external usage is
purged. goog.events no longer use goog.events.listeners_ for
anything meaningful.
|
Code » | |
![]()
Map of computed "on" strings for IE event types. Caching
this removes an extra object allocation in goog.events.listen which
improves IE6 performance.
|
Code » | |
![]()
String used to prepend to IE event types.
|
Code » | |
![]()
Counter to create unique event ids.
|
Code » |