Loading...
Searching...
No Matches
Engine/Events

Engine-level event management infrastructure. More...

Collaboration diagram for Engine/Events:

Classes

class  ml::EventDispatcher
 Base class for all per-event dispatchers in the Malena event system. More...
class  ml::EventManager
 Centralized event bus for the Malena trait-based event system. More...
class  ml::EventReceiver
 Base class for all event-receiving traits. More...
class  ml::FrameDispatcher
 Base class for per-frame dispatchers in the Malena event system. More...

Typedefs

using ml::Callback = std::function<void()>
 Callback type for no-argument event handlers.
using ml::EventCallback = std::function<void(const std::optional<sf::Event>&)>
 Callback type for event handlers that receive the raw SFML event.

Enumerations

enum class  ml::Event {
  ml::Event::CLICK , ml::Event::HOVER , ml::Event::UNHOVER , ml::Event::MOUSE_PRESSED ,
  ml::Event::MOUSE_RELEASED , ml::Event::MOUSE_MOVED , ml::Event::DRAG , ml::Event::SCROLL ,
  ml::Event::FOCUS , ml::Event::BLUR , ml::Event::KEYPRESS , ml::Event::KEY_RELEASE ,
  ml::Event::TEXT_ENTERED , ml::Event::SELECTED , ml::Event::DESELECTED , ml::Event::UPDATE ,
  ml::Event::INIT , ml::Event::READY , ml::Event::WINDOW_RESIZED , ml::Event::WINDOW_FOCUS_GAINED ,
  ml::Event::WINDOW_FOCUS_LOST
}
 Framework-level enum for all built-in Malena events. More...

Detailed Description

Engine-level event management infrastructure.

Typedef Documentation

◆ Callback

using ml::Callback = std::function<void()>

Callback type for no-argument event handlers.

Convenience alias accepted by all trait subscribe overloads that do not need the raw SFML event.

ml::Callback cb = []{ std::cout << "clicked\n"; };
myRect.onClick(cb);
std::function< void()> Callback
Callback type for no-argument event handlers.
Definition Callback.h:49

Definition at line 49 of file Callback.h.

◆ EventCallback

using ml::EventCallback = std::function<void(const std::optional<sf::Event>&)>

Callback type for event handlers that receive the raw SFML event.

Used as the parameter type when subscribing via subscribe(event, EventCallback). The std::optional<sf::Event> is non-empty for input events and std::nullopt for frame (UPDATE) events.

ml::EventCallback cb = [](const std::optional<sf::Event>& e) {
if (auto* kp = e->getIf<sf::Event::KeyPressed>())
std::cout << "key pressed\n";
};
myRect.subscribe(ml::Event::KEYPRESS, cb);
std::function< void(const std::optional< sf::Event > &)> EventCallback
Callback type for event handlers that receive the raw SFML event.
Definition Callback.h:35
@ KEYPRESS
Key pressed while component has focus.
Definition Event.h:55

Definition at line 35 of file Callback.h.

Enumeration Type Documentation

◆ Event

enum class ml::Event
strong

Framework-level enum for all built-in Malena events.

All built-in traits use this enum internally. User code can also use these values directly with subscribe, unsubscribe, and publish instead of relying on trait convenience methods.

Usage

// Via trait convenience methods (recommended)
myRect.onClick([]{ ... });
myRect.onHover([]{ ... });
// Via raw enum (advanced)
myRect.unsubscribe(ml::Event::CLICK);
myRect.unsubscribeAll();
@ CLICK
Mouse button released over component.
Definition Event.h:39
See also
Clickable, Hoverable, Focusable, Keyable, Updatable, Scrollable, Selectable
Enumerator
CLICK 

Mouse button released over component.

HOVER 

Mouse entered component bounds.

UNHOVER 

Mouse left component bounds.

MOUSE_PRESSED 

Raw mouse button pressed over component.

MOUSE_RELEASED 

Raw mouse button released over component.

MOUSE_MOVED 

Mouse moved anywhere in window.

DRAG 

Component is being dragged.

SCROLL 

Mouse wheel scrolled over component.

FOCUS 

Component gained keyboard focus.

BLUR 

Component lost keyboard focus.

KEYPRESS 

Key pressed while component has focus.

KEY_RELEASE 

Key released while component has focus.

TEXT_ENTERED 

Unicode character entered while component has focus.

SELECTED 

Component was programmatically selected.

DESELECTED 

Component was programmatically deselected.

UPDATE 

Every frame, before drawing.

INIT 

Fired once before the first frame — use to configure properties and register components.

READY 

Fired once after INIT — all components are registered and the object is ready to run.

WINDOW_RESIZED 

Application window was resized.

WINDOW_FOCUS_GAINED 

Application window gained OS focus.

WINDOW_FOCUS_LOST 

Application window lost OS focus.

Definition at line 36 of file Event.h.