Loading...
Searching...
No Matches
ml::Clickable Class Reference

#include <Clickable.h>

Inheritance diagram for ml::Clickable:

Public Member Functions

void onClick (std::function< void()> callback)
 Register a no-argument callback invoked when this component is clicked.
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.
virtual void process (const std::string &key, const std::optional< sf::Event > &event)
 Invoke all callbacks registered for key.
template<typename ENUM_TYPE>
void process (ENUM_TYPE eventName, const std::optional< sf::Event > &event)
 Invoke all callbacks registered for eventName.

Detailed Description

Definition at line 41 of file Clickable.h.

Member Function Documentation

◆ onClick() [1/2]

void ml::Clickable::onClick ( std::function< void()> callback)

Register a no-argument callback invoked when this component is clicked.

Replaces any previously registered onClick callback. The callback fires after the mouse button is released over this component.

Parameters
callbackFunction invoked with no arguments on click.

◆ onClick() [2/2]

void ml::Clickable::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.

Replaces any previously registered onClick callback.

Parameters
callbackFunction invoked with the SFML event on click.

◆ process() [1/2]

virtual void ml::EventReceiver::process ( const std::string & key,
const std::optional< sf::Event > & event )
virtualinherited

Invoke all callbacks registered for key.

Called by framework dispatchers. key is the string produced by EnumKey::get(eventEnum).

Parameters
keyString key identifying the event.
eventSFML event forwarded to each callback.

◆ process() [2/2]

template<typename ENUM_TYPE>
void ml::EventReceiver::process ( ENUM_TYPE eventName,
const std::optional< sf::Event > & event )
inherited

Invoke all callbacks registered for eventName.

Template overload that accepts any enum value directly, converting to a string key via EnumKey::get() internally.

Template Parameters
ENUM_TYPEAny enum type.
Parameters
eventNameThe enum value identifying the event.
eventSFML event forwarded to each callback.

The documentation for this class was generated from the following file: