Base class for all event-receiving traits. More...
#include <Malena/Engine/Events/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. | |
Public Attributes | |
| Core * | _selfCore = nullptr |
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 41 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. |
| Core* ml::EventReceiver::_selfCore = nullptr |
The owning Core, stamped by Core's constructor.
Traits subscribe from inside their OWN constructors (ml::TextInput calls onFocus(), ComponentCore subscribes to CLICK/HOVER/DRAG), at which point the derived type does not exist yet. Recovering the Core by dynamic_cast there is undefined: Clang returns something usable, MSVC throws "Access violation - no RTTI data!" and aborts the process. Core sets this on every one of its EventReceiver subobjects before any derived constructor runs, so no RTTI is ever needed.
Definition at line 93 of file EventReceiver.h.