Top
You are looking at an outdated 7.0.0 version of this document. Switch to the 8.0.1 version to see the up to date information.

namespace anychart.graphics.events Improve this Doc

A namespace of all global functions of the ACGraph event model.

Functions Overview

listen()Adds an event listener for an event to a DOM node or to an implementing object.
listenOnce()Adds an event listener for a certain event to a DOM node or to an implementing object.
removeAll()Removes all listeners from an object. You can also optionally
unlisten()Removes a listener added using listen() or listenOnce() methods.
unlistenByKey()Removes an event listener which was added with listen() by the key

Enums Overview

anychart.graphics.events.EventTypeConstants for event names.

Classes Overview

anychart.graphics.events.BrowserEventEncapsulates browser event for anychart.graphics.

Functions Description

listen

Adds an event listener for an event to a DOM node or to an implementing object. goog.events.EventTarget. The listener can be added to an object once, and if it is added one more time, its key will be returned.
Note Notice that if the existing listener is one-off (added using listenOnce), it will cease to be such after calling the listen() method.

Params:

Name Type Default Description
src goog.events.ListenableType
The object to attach the event listener to.
type string | Array.<string>
The type of event or the array of types.
listener function | Object | null
The event listener or the object with the handleEvent function.
capt boolean
false
Calls event handling in the capture phase (“false” by default).
handler Object
The element in scope of which the listener is called.

Returns:

goog.events.Key - The unique key for the event listener.

Try it:

listenOnce

Adds an event listener for a certain event to a DOM node or to an implementing object. goog.events.EventTarget. After the event is called, its handler will be deleted.
If the event handler being added already exists, listenOnce will do nothing.
Note In particular, if the handler is already registered using listen(), listenOnce() will not make it one-off. Similarly, if a one-off listener already exists, listenOnce will not change it (it wil remain one-off).

Params:

Name Type Default Description
src goog.events.ListenableType
The object to attach the event listener to.
type string | Array.<string>
The type of event or the array of types.
listener function | Object | null
The event listener.
capt boolean
false
Calls event handling in the capture phase.
handler Object
The element in scope of which the listener is called.

Returns:

goog.events.Key - The unique key for the event listener.

Try it:

removeAll

Removes all listeners from an object. You can also optionally remove listeners of some particular type.

Params:

Name Type Description
obj goog.events.ListenableType Object to remove listeners from.
type string Type of event to be removed, default is all types.

Returns:

number - Number of listeners removed.

Try it:

unlisten

Removes a listener added using listen() or listenOnce() methods.

Params:

Name Type Description
src goog.events.ListenableType The object on which to stop listening to the event.
type string | Array.<string> The type of event or the array of types of events you want to stop listening to.
listener function | Object | null The listener to be removed.
capt boolean In DOM-compatible browsers this parameter defines if the listener is called in the capture or in the bubble phase of the event.
handler Object The element in scope of which the listener is called.

Returns:

boolean - Shows if the removed listener existed.

Try it:

unlistenByKey

Removes an event listener which was added with listen() by the key returned by listen() or listenOnce().

Params:

Name Type Description
key goog.events.Key The key returned by listen() for this event listener.

Returns:

boolean - indicating whether the listener was there to remove.

Try it: