Base class for all per-event dispatchers in the Malena event system. More...
#include <EventDispatcher.h>
Public Member Functions | |
| void | fire (const std::optional< sf::Event > &event) override=0 |
| Deliver this event to all matching registered components. | |
| bool | occurred (const std::optional< sf::Event > &event) override=0 |
Return true when the incoming SFML event should trigger this dispatcher. | |
Base class for all per-event dispatchers in the Malena event system.
EventDispatcher is the class you inherit from to create a new event trait. It narrows Fireable to the SFML-event–driven path only: the no-argument fire() and occurred() overloads inherited from Fireable are sealed final so you only need to implement the two event-taking versions.
A complete event trait requires three pieces:
EventReceiver and exposes a friendly callback registration method (onClick, onHover, etc.) that stores a callback via Fireable::addCallback.EventDispatcher and implements occurred(), filter(), and fire(). Registered as a singleton with the event system via ML_EXPORT.ML_EXPORT(MyDispatcher) — placed after the class definition in the header. Creates the singleton and registers it with Fireable at startup.| Method | Called by | Purpose |
|---|---|---|
occurred(event) | AppManager each frame | Return true when this SFML event (or frame tick) should trigger processing. |
filter(event, component) | Framework, after occurred | Return true for each Core component that should receive this event. Default returns true for all. |
fire(event) | Framework, after filtering | Iterate registered components and call process() on those that pass the filter. |
Definition at line 88 of file EventDispatcher.h.
|
overridepure virtual |
Deliver this event to all matching registered components.
Called by the framework after occurred() returns true. Typically iterates the component list and calls process() on each component that passes filter().
| event | The SFML event that triggered this dispatch, or std::nullopt for synthetic/frame-driven events. |
Implemented in ml::DraggableDispatcher.
|
overridepure virtual |
Return true when the incoming SFML event should trigger this dispatcher.
Called once per event by the framework before any components are visited. Return false to skip the entire dispatch pass for this event.
| event | The SFML event to evaluate, or std::nullopt. |
true if this dispatcher should fire for event. Implemented in ml::DraggableDispatcher.