Top
You are looking at an outdated 7.13.1 version of this document. Switch to the 7.14.3 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.
unlisten()Removes a listener added using listen() or listenOnce() methods.
unlistenByKey()Removes an event listener which was added with listen() by the key returned by listen() or listenOnce().

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.

Params:

Name Type Default Description
target anychart.graphics.vector.Element
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.
handler Object
The element in scope of which the listener is called.

Returns:

Object - 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.

Params:

Name Type Default Description
target anychart.graphics.vector.Element
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:

Object - The unique key for the event listener.

Try it:

removeAll

Removes all listeners from an object.

Params:

Name Type Description
target anychart.graphics.vector.Element The 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
target anychart.graphics.vector.Element 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 Object The key returned by listen() for this event listener.

Returns:

boolean - Indicating whether the listener was there to remove.

Try it: