cocos2d-x  3.0-alpha0
 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>

Public Member Functions

void addEventListenerWithSceneGraphPriority (EventListener *listener, Node *node)
 Adds a event listener for a specified event with the priority of scene graph. More...
 
var addEventListenerWithSceneGraphPriority ( var listener, var 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 removeListenersForEventType (const std::string &eventType)
 Removes all listeners with the same event type. More...
 
void removeAllListeners ()
 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, bool forceSortListeners=false)
 Dispatches the event Also removes all EventListeners marked for deletion from the event dispatcher list. More...
 
local dispatchEvent ( local event, local false)
 Dispatches the event Also removes all EventListeners marked for deletion from the event dispatcher list. More...
 
void setDirtyForEventType (const std::string &eventType, bool isDirty)
bool isDirtyForEventType (const std::string &eventType)
 ~EventDispatcher ()
 Destructor of EventDispatcher. More...
 

Static Public Member Functions

static EventDispatchergetInstance ()
 Gets the singleton of EventDispatcher. More...
 
local getInstance ()
 Gets the singleton of EventDispatcher. More...
 
static void destroyInstance ()
 Destroys the singleton of EventDispatcher. 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

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'.
static void destroyInstance ( )
static

Destroys the singleton of EventDispatcher.

var destroyInstance ( )
static

Destroys the singleton of EventDispatcher.

local destroyInstance ( )
static

Destroys the singleton of EventDispatcher.

void dispatchEvent ( Event event,
bool  forceSortListeners = false 
)

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

var dispatchEvent ( var  event,
var  forceSortListeners = false 
)

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

local dispatchEvent ( local  event,
local  forceSortListeners = false 
)

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

static EventDispatcher* getInstance ( )
static

Gets the singleton of EventDispatcher.

var getInstance ( )
static

Gets the singleton of EventDispatcher.

local getInstance ( )
static

Gets the singleton of EventDispatcher.

bool isDirtyForEventType ( const std::string &  eventType)
var isDirtyForEventType ( var  eventType)
local isDirtyForEventType ( local  eventType)
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 removeAllListeners ( )

Removes all listeners.

var removeAllListeners ( )

Removes all listeners.

local removeAllListeners ( )

Removes all listeners.

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 removeListenersForEventType ( const std::string &  eventType)

Removes all listeners with the same event type.

var removeListenersForEventType ( var  eventType)

Removes all listeners with the same event type.

local removeListenersForEventType ( local  eventType)

Removes all listeners with the same event type.

void setDirtyForEventType ( const std::string &  eventType,
bool  isDirty 
)
var setDirtyForEventType ( var  eventType,
var  isDirty 
)
local setDirtyForEventType ( local  eventType,
local  isDirty 
)
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.


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