Loading...
Searching...
No Matches
Hoverable.h
Go to the documentation of this file.
1//
2// Created by Dave Smith on 3/20/26.
3//
4
5#ifndef HOVERABLE_H
6#define HOVERABLE_H
7
11
12namespace ml
13{
42 class Hoverable : public EventReceiver
43 {
44 public:
51 void onHover(std::function<void()> callback);
52
59 void onHover(std::function<void(const std::optional<sf::Event>& event)> callback);
60
67 void onUnhover(std::function<void()> callback);
68
75 void onUnhover(std::function<void(const std::optional<sf::Event>& event)> callback);
76 };
77
79 class HoverableDispatcher : public EventDispatcher
80 {
81 public:
82 bool occurred(const std::optional<sf::Event>& event) override;
83 bool filter(const std::optional<sf::Event>& event, Core* component) override;
84 void fire(const std::optional<sf::Event>& event) override;
85 };
87
88} // namespace ml
89
90ML_EXPORT(HoverableDispatcher)
91#endif // HOVERABLE_H
#define ML_EXPORT(ClassName)
Register a Malena type with the framework.
Definition Export.h:38
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.
Trait that adds mouse-hover and mouse-leave callbacks to any Core object.
Definition Hoverable.h:43
void onHover(std::function< void()> callback)
Register a no-argument callback invoked when the mouse enters this component's bounds.
void onUnhover(std::function< void(const std::optional< sf::Event > &event)> callback)
Register a callback invoked when the mouse leaves this component's bounds, receiving the raw SFML eve...
void onUnhover(std::function< void()> callback)
Register a no-argument callback invoked when the mouse leaves this component's bounds.
void onHover(std::function< void(const std::optional< sf::Event > &event)> callback)
Register a callback invoked when the mouse enters this component's bounds, receiving the raw SFML eve...
Definition Component.h:18