Class representing an event. More...
#include <Inventor/SbEventHandler.h>
Public Member Functions | |
void | operator() (ArgType arg) |
Call all registered callbacks. | |
void | add (void(*f)(ArgType)) |
Add a static function callback for this event. | |
template<typename ClassType > | |
void | add (ClassType &a, void(ClassType::*f)(ArgType)) |
Add a member function callback for this event. | |
bool | remove (void(*f)(ArgType)) |
Remove a static function. | |
template<typename ClassType > | |
bool | remove (ClassType &a, void(ClassType::*f)(ArgType)) |
Remove a member function. | |
Class representing an event.
An SbEventHandler encapsulates a list of "callbacks" or "delegates" that will be called when an event occurs. We generally think of events as input events, like mouseMove or keyboard, but they can be anything, like starting a computation or notifying that an object's state has changed.
The callback signature must be:
All SbEventHandler callbacks must return void and have a single argument of type EventArg . This argument will generally be a structure containing information about the event and possibly methods to query additional information. In OpenInventor, all EventArg will inherit from the SbEventArg class, but it is not mandatory if you want to define your own events. In any case, EventArg must not be void
Callbacks are registered using one of the add() methods. You can register a free function, a static class method or a member class method.
Warning: All registered callbacks will be called exactly once, but the order is undefined.
Definition at line 100 of file SbEventHandler.h.
|
inline |
Add a member function callback for this event.
Definition at line 131 of file SbEventHandler.h.
|
inline |
Add a static function callback for this event.
Definition at line 123 of file SbEventHandler.h.
|
inline |
Call all registered callbacks.
arg | Argument that will be given to callback. |
Definition at line 109 of file SbEventHandler.h.
|
inline |
Remove a member function.
If you add the same callback several times, you must remove it several times.
Definition at line 161 of file SbEventHandler.h.
|
inline |
Remove a static function.
If you add the same callback several times, you must remove it several times.
Definition at line 142 of file SbEventHandler.h.