Class cc.eventManager
- Defined in: CCEventManager.js
Constructor Attributes | Constructor Name and Description |
---|---|
cc.eventManager is a singleton object which manages event listener subscriptions and event dispatching. |
Method Summary
Class Detail
cc.eventManager is a singleton object which manages event listener subscriptions and event dispatching.
The EventListener list is managed in such way so that event listeners can be added and removed
while events are being dispatched.
Method Detail
-
{cc.EventListener} addCustomListener(eventName, callback)Adds a Custom event listener. It will use a fixed priority of 1.
- Parameters:
- {string} eventName
- {function} callback
- Returns:
- {cc.EventListener} the generated event. Needed in order to remove the event from the dispatcher
-
{cc.EventListener} addListener(listener, nodeOrPriority)
Adds a event listener for a specified event.
if the parameter "nodeOrPriority" is a node, it means to add a event listener for a specified event with the priority of scene graph.
if the parameter "nodeOrPriority" is a Number, it means to add a event listener for a specified event with the fixed priority.
- Parameters:
- {cc.EventListener|Object} listener
- The listener of a specified event or a object of some event parameters.
- {cc.Node|Number} nodeOrPriority
- The priority of the listener is based on the draw order of this node or fixedPriority The fixed priority of the listener.
- Returns:
- {cc.EventListener} Return the listener. Needed in order to remove the event from the dispatcher.
-
dispatchCustomEvent(eventName, optionalUserData)Dispatches a Custom Event with a event name an optional user data
- Parameters:
- {string} eventName
- {*} optionalUserData
-
dispatchEvent(event)Dispatches the event, also removes all EventListeners marked for deletion from the event dispatcher list.
- Parameters:
- {cc.Event} event
-
{boolean} isEnabled()Checks whether dispatching events is enabled
- Returns:
- {boolean}
-
pauseTarget(node, recursive)Pauses all listeners which are associated the specified target.
- Parameters:
- {cc.Node} node
- {Boolean} recursive Optional, Default: false
-
removeAllListeners()Removes all listeners
-
removeCustomListeners(customEventName)Removes all custom listeners with the same event name
- Parameters:
- {string} customEventName
-
removeListener(listener)Remove a listener
- Parameters:
- {cc.EventListener} listener
- an event listener or a registered node target
-
removeListeners(listenerType, recursive)Removes all listeners with the same event listener type or removes all listeners of a node
- Parameters:
- {Number|cc.Node} listenerType
- listenerType or a node
- {Boolean} recursive Optional, Default: false
-
resumeTarget(node, recursive)Resumes all listeners which are associated the specified target.
- Parameters:
- {cc.Node} node
- {Boolean} recursive Optional, Default: false
-
setEnabled(enabled)Whether to enable dispatching events
- Parameters:
- {boolean} enabled
-
setPriority(listener, fixedPriority)Sets listener's priority with fixed value.
- Parameters:
- {cc.EventListener} listener
- {Number} fixedPriority