Class for object-oriented handling of SFML events. More...
Public Types | |
typedef std::tr1::function < void(const sf::Event &) > | Listener |
Function type of listeners associated with Event. | |
Public Member Functions | |
SfmlEventSystem (sf::Window &window) | |
Constructor. | |
void | PollEvents () |
Polls events from the window and calls appropriate listeners. | |
Connection | ForwardEvents (const Listener &receiver) |
Forwards all events to a specific receiver. | |
void | ClearEventForwarders () |
Removes all connections of events that are forwarded. | |
void | TriggerEvent (const sf::Event &event) |
Fires an event. | |
Connection | Connect (const sf::Event::EventType &trigger, const Listener &listener) |
Connects an event to the specified listener. | |
void | ClearConnections (sf::Event::EventTypeidentifier) |
Disconnects listeners associated with a given event type. | |
void | ClearAllConnections () |
Disconnects all listeners. |
Class for object-oriented handling of SFML events.
Polls events of a window and forwards them to specific event listeners.
thor::SfmlEventSystem::SfmlEventSystem | ( | sf::Window & | window | ) | [explicit] |
Constructor.
window | The window from which events are going to be polled. |
void thor::EventSystem< sf::Event , sf::Event::EventType >::ClearAllConnections | ( | ) | [inherited] |
Disconnects all listeners.
Removes all event-listener connections, independently of the event type.
void thor::EventSystem< sf::Event , sf::Event::EventType >::ClearConnections | ( | sf::Event::EventType | identifier | ) | [inherited] |
Disconnects listeners associated with a given event type.
identifier | The event type identifier of which you want to remove all connected listeners. |
Removes all connections of events that are forwarded.
Disconnects all event connections that have been set up with ForwardEvents().
Connection thor::EventSystem< sf::Event , sf::Event::EventType >::Connect | ( | const sf::Event::EventType & | trigger, |
const Listener & | listener | ||
) | [inherited] |
Connects an event to the specified listener.
Duplicates are allowed (thus, the listener is invoked multiple times).
trigger | The event you want to associate with a listener function. |
listener | The function that is invoked when a trigger event is fired. |
Connection thor::SfmlEventSystem::ForwardEvents | ( | const Listener & | receiver | ) |
Forwards all events to a specific receiver.
This invokes the receiver function object for every event in the queue of the sf::Window (not just events of a given type). That can be useful for things like GUI hierarchies depending on events, too.
receiver | Function object that is called upon events. |
void thor::EventSystem< sf::Event , sf::Event::EventType >::TriggerEvent | ( | const sf::Event & | event | ) | [inherited] |
Fires an event.
Calls all listener functions that are currently associated with event.