Base class for all event-receiving traits. More...
#include <EventReceiver.h>
Public Member Functions | |
| virtual | ~EventReceiver ()=default |
| virtual void | process (const std::string &key, const std::optional< sf::Event > &event) |
Invoke all callbacks registered for key. | |
| template<typename ENUM_TYPE> | |
| void | process (ENUM_TYPE eventName, const std::optional< sf::Event > &event) |
Invoke all callbacks registered for eventName. | |
Base class for all event-receiving traits.
EventReceiver is the storage layer shared by every trait that handles events (Clickable, Hoverable, Keyable, etc.). It maintains a map of string keys to callback vectors, where each key is produced by EnumKey::get() from any ml::Event or manifest event enum value.
Framework dispatchers call process() to invoke stored callbacks. Traits call getCallbacks() to register them. User code interacts with EventReceiver only indirectly through the trait convenience methods (onClick, onHover, onUpdate, etc.).
Definition at line 36 of file EventReceiver.h.
|
virtualdefault |
|
virtual |
Invoke all callbacks registered for key.
Called by framework dispatchers. key is the string produced by EnumKey::get(eventEnum).
| key | String key identifying the event. |
| event | SFML event forwarded to each callback. |
| void ml::EventReceiver::process | ( | ENUM_TYPE | eventName, |
| const std::optional< sf::Event > & | event ) |
Invoke all callbacks registered for eventName.
Template overload that accepts any enum value directly, converting to a string key via EnumKey::get() internally.
| ENUM_TYPE | Any enum type. |
| eventName | The enum value identifying the event. |
| event | SFML event forwarded to each callback. |