#include <OpenGUI_EventHandler.h>
Inheritance diagram for OpenGUI::EventDelegate:

This delegate class is capable of binding to either C-style function pointers or object specific member function pointers. It performs the smoke and magic through an abstract interface class system, and the use of a very light template in the specific case of member function callbacks.
Public Member Functions | |
| EventDelegate (EventCallbackFunc *C_funcPtr) | |
| Create the delegate from a C function pointer. | |
| template<class CLASS, class ARGS_TYPE> | |
| EventDelegate (CLASS *classObjPtr, void(CLASS::*memberFunc)(Object *, ARGS_TYPE &)) | |
| Create the delegate from an object bound member function pointer. | |
| virtual void | onEvent (Object *sender, EventArgs &args) |
| Calls the function/member given at EventDelegate creation on event trigger. | |
| virtual void | onEventDestruction () |
| Automatically deletes self on event destruction. | |
| OpenGUI::EventDelegate::EventDelegate | ( | EventCallbackFunc * | C_funcPtr | ) | [inline] |
Create the delegate from a C function pointer.
obj is a pointer to a valid Object, and desiredEvent is a valid event for that Object. obj->getEvents()["desiredEvent"].add( new EventDelegate(&myCallback) );
| OpenGUI::EventDelegate::EventDelegate | ( | CLASS * | classObjPtr, | |
| void(CLASS::*)(Object *, ARGS_TYPE &) | memberFunc | |||
| ) | [inline] |
Create the delegate from an object bound member function pointer.
class MyClass{ public: void myMethod( Object* sender, EventArgs& args ){ //do something important } };
obj is a pointer to a valid Object, desiredEvent is a valid event for that Object, and myClassObj is a valid pointer to an instance of MyClass. obj->getEvents()["desiredEvent"].add( new EventDelegate(myClassObj, &MyClass::myMethod) );
| virtual void OpenGUI::EventDelegate::onEvent | ( | Object * | sender, | |
| EventArgs & | args | |||
| ) | [inline, virtual] |
Calls the function/member given at EventDelegate creation on event trigger.
Implements OpenGUI::EventHandler.
| virtual void OpenGUI::EventDelegate::onEventDestruction | ( | ) | [inline, virtual] |
Automatically deletes self on event destruction.
This is so that you do not need to retain a pointer to it. In fact, you probably shouldn't.
Reimplemented from OpenGUI::EventHandler.