GlistEngine
Loading...
Searching...
No Matches
gEventDispatcher Class Reference

#include <gEvent.h>

Public Member Functions

 gEventDispatcher (gEvent &event)
template<typename T, typename F>
bool dispatch (const F &func)

Detailed Description

Example usage:

void gCanvas::onEvent(gEvent& event) {
gEventDispatcher dispatcher(event);
dispatcher.dispatch<gSomethingEvent>(G_BIND_FUNCTION(onSomethingEvent)); // to bind functions inside the current class
dispatcher.dispatch<gSomethingEvent>(G_BIND_GLOBAL_FUNCTION(onSomethingEvent)); // to bind global functions without a class
}
bool gCanvas::onSomethingEvent(gSomethingEvent& event) {
gLogi("gCanvas") << "My something event is called!";
// Return true if event is handled, meaning that no other event function will be called.
return false;
}
gEventDispatcher(gEvent &event)
Definition gEvent.h:68
Definition gEvent.h:32
Definition gUtils.h:208
#define G_BIND_FUNCTION(fn)
Definition gEvent.h:97
#define G_BIND_GLOBAL_FUNCTION(fn)
Definition gEvent.h:98

Constructor & Destructor Documentation

◆ gEventDispatcher()

gEventDispatcher::gEventDispatcher ( gEvent & event)
inline

Member Function Documentation

◆ dispatch()

template<typename T, typename F>
bool gEventDispatcher::dispatch ( const F & func)
inline

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