Polycode
|
Can dispatch events. More...
Inherits Polycode::EventHandler.
Inherited by Polycode::Core, Polycode::CoreInput, Polycode::CoreServices, Polycode::Scene, Polycode::SceneEntity, Polycode::Screen, Polycode::ScreenEntity, Polycode::ScreenManager, Polycode::Timer, and Polycode::Tween.
Public Member Functions | |
EventDispatcher () | |
Default constructor. | |
void | removeAllHandlers () |
Removes all current event handlers from this dispatcher. | |
void | removeAllHandlersForListener (void *listener) |
Removes all current event handlers from this dispatcher for a specific event listener. | |
void | addEventListener (EventHandler *handler, int eventCode) |
Adds an event listener for a specific event code. | |
void | removeEventListener (EventHandler *handler, int eventCode) |
Removes a listener for a specific handler and event code. | |
void | dispatchEvent (Event *event, int eventCode) |
Dispatches an event to all handlers listening for the event code specified. |
Can dispatch events.
The event dispatcher is base class which allows its subclass to dispatch custom events which EventHandler subclasses can then listen to. EventDispatcher and EventHandler are the two main classes in the Polycode event system. If you are familiar with ActionScript3's event system, you will find this to be very similar, except that it uses integers for event codes for speed, rather than strings.
void Polycode::EventDispatcher::addEventListener | ( | EventHandler * | handler, |
int | eventCode | ||
) |
Adds an event listener for a specific event code.
Once a listener is registered for a specific event code, that listener will start getting event callbacks into the handleEvent() method.
handler | The event handler to add as a listener |
eventCode | The requested event code to listen to. |
void Polycode::EventDispatcher::dispatchEvent | ( | Event * | event, |
int | eventCode | ||
) |
Dispatches an event to all handlers listening for the event code specified.
event | Event class to dispatch to listeners. You can subclass the Event class to send data in your events. |
eventCode | The event code to dispatch the event for. |
void Polycode::EventDispatcher::removeAllHandlersForListener | ( | void * | listener | ) |
Removes all current event handlers from this dispatcher for a specific event listener.
Event | listener to remove handlers for. |
void Polycode::EventDispatcher::removeEventListener | ( | EventHandler * | handler, |
int | eventCode | ||
) |
Removes a listener for a specific handler and event code.
handler | The event handler to remove as a listener |
eventCode | The requested event code to remove listener for. |