Loading...
Searching...
No Matches
Clickable.h
Go to the documentation of this file.
1// Copyright (c) 2025 Dave R. Smith.
2// Malena Framework — Licensed under PolyForm Noncommercial 1.0.0; commercial use requires a paid license. See LICENSE.
3
4//
5// Created by Dave Smith on 3/20/26.
6//
7
8#ifndef MALENA_CLICKABLE_H
9#define MALENA_CLICKABLE_H
10
14#include <optional>
15namespace ml
16{
44 class Core;
46 {
47 public:
57 void onClick(std::function<void()> callback, bool overwrite = true);
58
69 void onClick(std::function<void(const std::optional<sf::Event>& event)> callback, bool overwrite = true);
70 };
71
73 class MALENA_API ClickableDispatcher : public EventDispatcher
74 {
75 inline static EventReceiver* _focused = nullptr;
76 public:
77 bool occurred(const std::optional<sf::Event>& event) override;
78 bool filter(const std::optional<sf::Event>& event, Core* component) override;
79 void fire(const std::optional<sf::Event>& event) override;
80 };
82
83} // namespace ml
84
85ML_EXPORT(ClickableDispatcher);
86#endif // MALENA_CLICKABLE_H
#define ML_EXPORT(ClassName)
Register a Malena type with the framework.
Definition Export.h:43
void onClick(std::function< void()> callback, bool overwrite=true)
Register a no-argument callback invoked when this component is clicked.
void onClick(std::function< void(const std::optional< sf::Event > &event)> callback, bool overwrite=true)
Register a callback invoked when this component is clicked, receiving the raw SFML event.
Virtual base class for all Malena framework objects.
Definition Core.h:97
Base class for all per-event dispatchers in the Malena event system.
Base class for all event-receiving traits.
#define MALENA_API
Definition Component.h:22