Guillaume 1.0.0
Guillaume.
Loading...
Searching...
No Matches
Event Class Reference

Represents a UI event with type, target, and optional data. More...

#include <event.hpp>

Public Member Functions

 Event (const std::string &type, std::shared_ptr< Component > target, const std::any &data=std::any())
 Construct an event.
 
const std::string & getType (void) const
 Get the event type.
 
std::shared_ptr< ComponentgetTarget (void) const
 Get the target component.
 
template<typename T >
getData (void) const
 Get the event data with type casting.
 
bool hasData (void) const
 Check if the event has data.
 

Detailed Description

Represents a UI event with type, target, and optional data.

The Event class encapsulates user interactions and system events that can be propagated through the component hierarchy. Events have a type (e.g., "click"), a target component, and optional type-erased data payload.

Constructor & Destructor Documentation

◆ Event()

Event::Event ( const std::string &  type,
std::shared_ptr< Component target,
const std::any &  data = std::any() 
)
inline

Construct an event.

Parameters
typeThe event type (e.g., "click", "hover", "change")
targetThe component that is the target of this event
dataOptional data payload associated with the event

Member Function Documentation

◆ getData()

template<typename T >
T Event::getData ( void  ) const
inline

Get the event data with type casting.

Template Parameters
TThe type to cast the data to
Returns
The event data cast to type T, or default-constructed T if no data

◆ getTarget()

std::shared_ptr< Component > Event::getTarget ( void  ) const
inline

Get the target component.

Returns
Shared pointer to the target component

◆ getType()

const std::string & Event::getType ( void  ) const
inline

Get the event type.

Returns
The event type string

◆ hasData()

bool Event::hasData ( void  ) const
inline

Check if the event has data.

Returns
true if data is present, false otherwise

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