A utility class that safely routes events to type-specific handler functions.
More...
#include <Event.h>
|
| EventHandler (Event &event) |
| Constructs an EventHandler for a specific event.
|
|
template<typename T> |
bool | TryHandle (HandlerFn< T > handler) |
| Attempts to handle an event if it matches the specified type.
|
|
A utility class that safely routes events to type-specific handler functions.
The EventHandler provides a type-safe way to handle different types of events by:
- Checking if an incoming event matches a specific type
- If matched, converting the event to its specific type safely
- Routing it to the appropriate handler function
Example usage:
return;
}
}
bool OnWindowClose(WindowCloseEvent& e) {
return true;
}
EventHandler(Event &event)
Constructs an EventHandler for a specific event.
Definition Event.h:119
Base class for the event system.
Definition Event.h:61
Event triggered when the window is closed.
Definition ApplicationEvent.h:49
- Note
- Handler functions should return true if they've handled the event and false if the event should continue propagating to other handlers.
◆ EventHandler()
AE::Events::EventHandler::EventHandler |
( |
Event & | event | ) |
|
|
inline |
Constructs an EventHandler for a specific event.
- Parameters
-
event | The event to potentially handle. |
◆ TryHandle()
template<typename T>
bool AE::Events::EventHandler::TryHandle |
( |
HandlerFn< T > | handler | ) |
|
|
inline |
Attempts to handle an event if it matches the specified type.
- Template Parameters
-
T | The specific event type to check for. |
- Parameters
-
handler | The function to handle the event if types match. |
- Returns
- true if the event type matched and the handler was called, false if the event was of a different type.
The documentation for this class was generated from the following file: