cocos2d-x  3.0alpha1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EventDispatcher Class Reference

This class manages event listener subscriptions and event dispatching. More...

#include <CCEventDispatcher.h>

Inheritance diagram for EventDispatcher:
Object

Public Member Functions

void addEventListenerWithSceneGraphPriority (EventListener *listener, Node *node)
 Adds a event listener for a specified event with the priority of scene graph. More...
 
void addEventListenerWithFixedPriority (EventListener *listener, int fixedPriority)
 Adds a event listener for a specified event with the fixed priority. More...
 
void removeEventListener (EventListener *listener)
 Remove a listener. More...
 
void removeEventListeners (EventListener::Type listenerType)
 Removes all listeners with the same event listener type. More...
 
void removeCustomEventListeners (const std::string &customEventName)
 Removes all custom listeners with the same event name. More...
 
void removeAllEventListeners ()
 Removes all listeners. More...
 
void setPriority (EventListener *listener, int fixedPriority)
 Sets listener's priority with fixed value. More...
 
void setEnabled (bool isEnabled)
 Whether to enable dispatching events. More...
 
bool isEnabled () const
 Checks whether dispatching events is enabled. More...
 
void dispatchEvent (Event *event)
 Dispatches the event Also removes all EventListeners marked for deletion from the event dispatcher list. More...
 
local dispatchEvent ( local event)
 Dispatches the event Also removes all EventListeners marked for deletion from the event dispatcher list. More...
 
 EventDispatcher ()
 Constructor of EventDispatcher. More...
 
 ~EventDispatcher ()
 Destructor of EventDispatcher. More...
 
- Public Member Functions inherited from Object
 Object ()
 Constructor. More...
 
virtual ~Object ()
void release ()
 Release the ownership immediately. More...
 
void retain ()
 Retains the ownership. More...
 
Objectautorelease ()
 Release the ownership sometime soon automatically. More...
 
bool isSingleReference () const
 Returns a boolean value that indicates whether there is only one reference to the object. More...
 
unsigned int retainCount () const
 Returns the object's current reference count. More...
 
virtual bool isEqual (const Object *object)
 Returns a boolean value that indicates whether this object and a given object are equal. More...
 
virtual void acceptVisitor (DataVisitor &visitor)
virtual void update (float dt)

Friends

class Node

Additional Inherited Members

- Public Attributes inherited from Object
unsigned int _ID
 object id, ScriptSupport need public _ID More...
 
int _luaID
 Lua reference id. More...
 
- Protected Attributes inherited from Object
unsigned int _reference
 count of references More...
 
unsigned int _autoReleaseCount
 count of autorelease More...
 

Detailed Description

This class manages event listener subscriptions and event dispatching.

The EventListener list is managed in such a way that event listeners can be added and removed even from within an EventListener, while events are being dispatched.

Constructor & Destructor Documentation

Constructor of EventDispatcher.

var EventDispatcher ( )

Constructor of EventDispatcher.

local EventDispatcher ( )

Constructor of EventDispatcher.

Destructor of EventDispatcher.

var ~EventDispatcher ( )

Destructor of EventDispatcher.

local ~EventDispatcher ( )

Destructor of EventDispatcher.

Member Function Documentation

void
addEventListenerWithFixedPriority
( EventListener listener,
int  fixedPriority 
)

Adds a event listener for a specified event with the fixed priority.

Parameters
listenerThe listener of a specified event.
fixedPriorityThe fixed priority of the listener.
Note
A lower priority will be called before the ones that have a higher value. 0 priority is forbidden for fixed priority since it's used for scene graph based priority.
var
addEventListenerWithFixedPriority
( var  listener,
var  fixedPriority 
)

Adds a event listener for a specified event with the fixed priority.

Parameters
listenerThe listener of a specified event.
fixedPriorityThe fixed priority of the listener.
Note
A lower priority will be called before the ones that have a higher value. 0 priority is forbidden for fixed priority since it's used for scene graph based priority.
local
addEventListenerWithFixedPriority
( local  listener,
local  fixedPriority 
)

Adds a event listener for a specified event with the fixed priority.

Parameters
listenerThe listener of a specified event.
fixedPriorityThe fixed priority of the listener.
Note
A lower priority will be called before the ones that have a higher value. 0 priority is forbidden for fixed priority since it's used for scene graph based priority.
void
addEventListenerWithSceneGraphPriority
( EventListener listener,
Node node 
)

Adds a event listener for a specified event with the priority of scene graph.

Parameters
listenerThe listener of a specified event.
nodeThe priority of the listener is based on the draw order of this node.
Note
The priority of scene graph will be fixed value 0. So the order of listener item in the vector will be ' <0, scene graph (0 priority), >0'.
var
addEventListenerWithSceneGraphPriority
( var  listener,
var  node 
)

Adds a event listener for a specified event with the priority of scene graph.

Parameters
listenerThe listener of a specified event.
nodeThe priority of the listener is based on the draw order of this node.
Note
The priority of scene graph will be fixed value 0. So the order of listener item in the vector will be ' <0, scene graph (0 priority), >0'.
local
addEventListenerWithSceneGraphPriority
( local  listener,
local  node 
)

Adds a event listener for a specified event with the priority of scene graph.

Parameters
listenerThe listener of a specified event.
nodeThe priority of the listener is based on the draw order of this node.
Note
The priority of scene graph will be fixed value 0. So the order of listener item in the vector will be ' <0, scene graph (0 priority), >0'.
void dispatchEvent ( Event event)

Dispatches the event Also removes all EventListeners marked for deletion from the event dispatcher list.

var dispatchEvent ( var  event)

Dispatches the event Also removes all EventListeners marked for deletion from the event dispatcher list.

local dispatchEvent ( local  event)

Dispatches the event Also removes all EventListeners marked for deletion from the event dispatcher list.

bool isEnabled ( ) const

Checks whether dispatching events is enabled.

var isEnabled ( )

Checks whether dispatching events is enabled.

local isEnabled ( )

Checks whether dispatching events is enabled.

void removeAllEventListeners ( )

Removes all listeners.

var removeAllEventListeners ( )

Removes all listeners.

local removeAllEventListeners ( )

Removes all listeners.

void removeCustomEventListeners ( const std::string &  customEventName)

Removes all custom listeners with the same event name.

var removeCustomEventListeners ( var  customEventName)

Removes all custom listeners with the same event name.

local removeCustomEventListeners ( local  customEventName)

Removes all custom listeners with the same event name.

void removeEventListener ( EventListener listener)

Remove a listener.

Parameters
listenerThe specified event listener which needs to be removed.
var removeEventListener ( var  listener)

Remove a listener.

Parameters
listenerThe specified event listener which needs to be removed.
local removeEventListener ( local  listener)

Remove a listener.

Parameters
listenerThe specified event listener which needs to be removed.
void removeEventListeners ( EventListener::Type  listenerType)

Removes all listeners with the same event listener type.

var removeEventListeners ( var  listenerType)

Removes all listeners with the same event listener type.

local removeEventListeners ( local  listenerType)

Removes all listeners with the same event listener type.

void setEnabled ( bool  isEnabled)

Whether to enable dispatching events.

var setEnabled ( var  isEnabled)

Whether to enable dispatching events.

local setEnabled ( local  isEnabled)

Whether to enable dispatching events.

void setPriority ( EventListener listener,
int  fixedPriority 
)

Sets listener's priority with fixed value.

var setPriority ( var  listener,
var  fixedPriority 
)

Sets listener's priority with fixed value.

local setPriority ( local  listener,
local  fixedPriority 
)

Sets listener's priority with fixed value.

Friends And Related Function Documentation

friend class Node
friend

The documentation for this class was generated from the following file: