Loading...
Searching...
No Matches
Clickable.h
Go to the documentation of this file.
1//
2// Created by Dave Smith on 3/20/26.
3//
4
5#ifndef CLICKABLE_H
6#define CLICKABLE_H
7
10
11namespace ml
12{
40 class Core;
41 class Clickable : public EventReceiver
42 {
43 public:
52 void onClick(std::function<void()> callback);
53
62 void onClick(std::function<void(const std::optional<sf::Event>& event)> callback);
63 };
64
66 class ClickableDispatcher : public EventDispatcher
67 {
68 inline static EventReceiver* _focused = nullptr;
69 public:
70 bool occurred(const std::optional<sf::Event>& event) override;
71 bool filter(const std::optional<sf::Event>& event, Core* component) override;
72 void fire(const std::optional<sf::Event>& event) override;
73 };
75
76} // namespace ml
77
78ML_EXPORT(ClickableDispatcher);
79#endif // CLICKABLE_H
#define ML_EXPORT(ClassName)
Register a Malena type with the framework.
Definition Export.h:38
void onClick(std::function< void(const std::optional< sf::Event > &event)> callback)
Register a callback invoked when this component is clicked, receiving the raw SFML event.
void onClick(std::function< void()> callback)
Register a no-argument callback invoked when this component is clicked.
Virtual base class for all Malena framework objects.
Definition Core.h:67
Base class for all per-event dispatchers in the Malena event system.
Base class for all event-receiving traits.
Definition Component.h:18