Loading...
Searching...
No Matches
ml::EventReceiver Class Reference

Base class for all event-receiving traits. More...

#include <EventReceiver.h>

Inheritance diagram for ml::EventReceiver:

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.

Detailed Description

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.).

See also
Clickable, Hoverable, Focusable, Keyable, Updatable, Scrollable, Unsubscribable, EventsManager, EnumKey

Definition at line 36 of file EventReceiver.h.

Constructor & Destructor Documentation

◆ ~EventReceiver()

virtual ml::EventReceiver::~EventReceiver ( )
virtualdefault

Member Function Documentation

◆ process() [1/2]

virtual void ml::EventReceiver::process ( const std::string & key,
const std::optional< sf::Event > & event )
virtual

Invoke all callbacks registered for key.

Called by framework dispatchers. key is the string produced by EnumKey::get(eventEnum).

Parameters
keyString key identifying the event.
eventSFML event forwarded to each callback.

◆ process() [2/2]

template<typename ENUM_TYPE>
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.

Template Parameters
ENUM_TYPEAny enum type.
Parameters
eventNameThe enum value identifying the event.
eventSFML event forwarded to each callback.

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