This class manages event listener subscriptions and event dispatching. More...
Inherits Ref.
Public Member Functions | |
| void | addEventListenerWithSceneGraphPriority (EventListener *listener, Node *node) |
| Adds a event listener for a specified event with the priority of scene graph. More... | |
| local | addEventListenerWithSceneGraphPriority ( local listener, local 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... | |
| EventListenerCustom * | addCustomEventListener (const std::string &eventName, const std::function< void(EventCustom *)> &callback) |
| Adds a Custom event listener. More... | |
| void | removeEventListener (EventListener *listener) |
| Remove a listener. More... | |
| void | removeEventListenersForType (EventListener::Type listenerType) |
| Removes all listeners with the same event listener type. More... | |
| void | removeEventListenersForTarget (Node *target, bool recursive=false) |
| Removes all listeners which are associated with the specified target. More... | |
| void | removeCustomEventListeners (const std::string &customEventName) |
| Removes all custom listeners with the same event name. More... | |
| void | removeAllEventListeners () |
| Removes all listeners. | |
| void | pauseEventListenersForTarget (Node *target, bool recursive=false) |
| Pauses all listeners which are associated the specified target. More... | |
| local | pauseEventListenersForTarget ( local target, local false) |
| Pauses all listeners which are associated the specified target. More... | |
| void | resumeEventListenersForTarget (Node *target, bool recursive=false) |
| Resumes all listeners which are associated the specified target. 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. More... | |
| void | dispatchCustomEvent (const std::string &eventName, void *optionalUserData=nullptr) |
| Dispatches a Custom Event with a event name an optional user data. More... | |
| EventDispatcher () | |
| Constructor of EventDispatcher. | |
| ~EventDispatcher () | |
| Destructor of EventDispatcher. | |
Public Member Functions inherited from Ref | |
| void | retain () |
| Retains the ownership. More... | |
| void | release () |
| Releases the ownership immediately. More... | |
| Ref * | autorelease () |
| Releases the ownership sometime soon automatically. More... | |
| unsigned int | getReferenceCount () const |
| Returns the Ref's current reference count. More... | |
| virtual | ~Ref () |
| Destructor. More... | |
Additional Inherited Members | |
Public Attributes inherited from Ref | |
| unsigned int | _ID |
| object id, ScriptSupport need public _ID | |
| int | _luaID |
| Lua reference id. | |
| void * | _scriptObject |
| scriptObject, support for swift | |
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.
| void addEventListenerWithSceneGraphPriority |
( | EventListener * | listener, |
| Node * | node | ||
| ) |
Adds a event listener for a specified event with the priority of scene graph.
| listener | The listener of a specified event. |
| node | The priority of the listener is based on the draw order of this node. |
| local addEventListenerWithSceneGraphPriority |
( | local | listener, |
| local | node | ||
| ) |
Adds a event listener for a specified event with the priority of scene graph.
| listener | The listener of a specified event. |
| node | The priority of the listener is based on the draw order of this node. |
| void addEventListenerWithFixedPriority |
( | EventListener * | listener, |
| int | fixedPriority | ||
| ) |
Adds a event listener for a specified event with the fixed priority.
| listener | The listener of a specified event. |
| fixedPriority | The fixed priority of the listener. |
| local addEventListenerWithFixedPriority |
( | local | listener, |
| local | fixedPriority | ||
| ) |
Adds a event listener for a specified event with the fixed priority.
| listener | The listener of a specified event. |
| fixedPriority | The fixed priority of the listener. |
| EventListenerCustom* addCustomEventListener |
( | const std::string & | eventName, |
| const std::function< void(EventCustom *)> & | callback | ||
| ) |
Adds a Custom event listener.
It will use a fixed priority of 1.
| eventName | A given name of the event. |
| callback | A given callback method that associated the event name. |
| local addCustomEventListener | ( | local | eventName, |
| local | callback | ||
| ) |
Adds a Custom event listener.
It will use a fixed priority of 1.
| eventName | A given name of the event. |
| callback | A given callback method that associated the event name. |
| void removeEventListener | ( | EventListener * | listener | ) |
Remove a listener.
| listener | The specified event listener which needs to be removed. |
| local removeEventListener | ( | local | listener | ) |
Remove a listener.
| listener | The specified event listener which needs to be removed. |
| void removeEventListenersForType | ( | EventListener::Type | listenerType | ) |
Removes all listeners with the same event listener type.
| listenerType | A given event listener type which needs to be removed. |
| local removeEventListenersForType | ( | local | listenerType | ) |
Removes all listeners with the same event listener type.
| listenerType | A given event listener type which needs to be removed. |
| void removeEventListenersForTarget | ( | Node * | target, |
| bool | recursive = false |
||
| ) |
Removes all listeners which are associated with the specified target.
| target | A given target node. |
| recursive | True if remove recursively, the default value is false. |
| local removeEventListenersForTarget | ( | local | target, |
| local | recursive = false |
||
| ) |
Removes all listeners which are associated with the specified target.
| target | A given target node. |
| recursive | True if remove recursively, the default value is false. |
| void removeCustomEventListeners | ( | const std::string & | customEventName | ) |
Removes all custom listeners with the same event name.
| customEventName | A given event listener name which needs to be removed. |
| local removeCustomEventListeners | ( | local | customEventName | ) |
Removes all custom listeners with the same event name.
| customEventName | A given event listener name which needs to be removed. |
| void pauseEventListenersForTarget | ( | Node * | target, |
| bool | recursive = false |
||
| ) |
Pauses all listeners which are associated the specified target.
| target | A given target node. |
| recursive | True if pause recursively, the default value is false. |
| local pauseEventListenersForTarget | ( | local | target, |
| local | recursive = false |
||
| ) |
Pauses all listeners which are associated the specified target.
| target | A given target node. |
| recursive | True if pause recursively, the default value is false. |
| void resumeEventListenersForTarget | ( | Node * | target, |
| bool | recursive = false |
||
| ) |
Resumes all listeners which are associated the specified target.
| target | A given target node. |
| recursive | True if resume recursively, the default value is false. |
| local resumeEventListenersForTarget | ( | local | target, |
| local | recursive = false |
||
| ) |
Resumes all listeners which are associated the specified target.
| target | A given target node. |
| recursive | True if resume recursively, the default value is false. |
| void setPriority | ( | EventListener * | listener, |
| int | fixedPriority | ||
| ) |
Sets listener's priority with fixed value.
| listener | A given listener. |
| fixedPriority | The fixed priority value. |
| local setPriority | ( | local | listener, |
| local | fixedPriority | ||
| ) |
Sets listener's priority with fixed value.
| listener | A given listener. |
| fixedPriority | The fixed priority value. |
| void setEnabled | ( | bool | isEnabled | ) |
Whether to enable dispatching events.
| isEnabled | True if enable dispatching events. |
| local setEnabled | ( | local | isEnabled | ) |
Whether to enable dispatching events.
| isEnabled | True if enable dispatching events. |
| bool isEnabled | ( | ) | const |
Checks whether dispatching events is enabled.
| local isEnabled | ( | ) |
Checks whether dispatching events is enabled.
| void dispatchEvent | ( | Event * | event | ) |
Dispatches the event.
Also removes all EventListeners marked for deletion from the event dispatcher list.
| event | The event needs to be dispatched. |
| local dispatchEvent | ( | local | event | ) |
Dispatches the event.
Also removes all EventListeners marked for deletion from the event dispatcher list.
| event | The event needs to be dispatched. |
| void dispatchCustomEvent | ( | const std::string & | eventName, |
| void * | optionalUserData = nullptr |
||
| ) |
Dispatches a Custom Event with a event name an optional user data.
| eventName | The name of the event which needs to be dispatched. |
| optionalUserData | The optional user data, it's a void*, the default value is nullptr. |
| local dispatchCustomEvent | ( | local | eventName, |
| local | optionalUserData = nullptr |
||
| ) |
Dispatches a Custom Event with a event name an optional user data.
| eventName | The name of the event which needs to be dispatched. |
| optionalUserData | The optional user data, it's a void*, the default value is nullptr. |