List of all members | Public Attributes
thor::ActionContext< ActionId > Struct Template Reference

Structure containing information about the context in which an action has occurred. More...

Public Attributes

sf::Window * window
 Pointer to sf::Window passed to the ActionMap::invokeCallbacks(). More...
 
const sf::Event * event
 Pointer to a sf::Event that contributed to this action's activation. More...
 
ActionId actionId
 Identifier of the action. More...
 

Detailed Description

template<typename ActionId>
struct thor::ActionContext< ActionId >

Structure containing information about the context in which an action has occurred.

This structure aggregates the events and the realtime input that were used to activate a specific action. Its objects are passed to the EventSystem class, which makes it possible for listener functions to get information about the action's trigger (e.g. the sf::Event::KeyPressed event for key presses).

See also
ActionMap::invokeCallbacks()

Member Data Documentation

template<typename ActionId>
ActionId thor::ActionContext< ActionId >::actionId

Identifier of the action.

This is the ID referring to this action, used as argument for ActionMap::operator[] and EventSystem::connect().

template<typename ActionId>
const sf::Event* thor::ActionContext< ActionId >::event

Pointer to a sf::Event that contributed to this action's activation.

Do not store the pointer. It is a null pointer if the action is not an event action (triggered by a sf::Event), but a realtime action (triggered by sf::Mouse, sf::Keyboard or sf::Joystick). The event type behind the pointer depends on the action:

How was the thor::Action constructed? Possible values for event->type
Keyboard/mouse/joystick actions constructed with PressOnce KeyPressed, MouseButtonPressed or JoystickButtonPressed
Keyboard/mouse/joystick actions constructed with ReleaseOnce KeyReleased, MouseButtonReleased or JoystickButtonReleased
Keyboard/mouse/joystick actions constructed with Hold The pointer is nullptr and thus cannot be dereferenced
Miscellaneous SFML event actions The sf::Event::EventType specified in the Action constructor
Actions combined with ||, && and ! operators The one event type in the operands, unless the pointer is nullptr

If this context is created for an Action that involves logical operators, then this event member will represent zero or one involved event actions. Note that meaningful combinations of logical operators involve at most one event action and possibly multiple realtime actions that can be active at the same time (see operator documentation). Example actions are event && realtime or event || event. Thus, only one context will be built for logical combinations, and at most one event will be stored in it.

template<typename ActionId>
sf::Window* thor::ActionContext< ActionId >::window

Pointer to sf::Window passed to the ActionMap::invokeCallbacks().

Use this variable to access the window inside a callback function. This pointer can be nullptr if you didn't specify a window when calling ActionMap::invokeCallbacks().


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