Cafu Engine
Event Handlers (Callbacks)

Some of our script classes have methods that are called event handlers or event callbacks.

The related documentation groups such methods in a separate section that is labelled "Event Handlers (Callbacks)".

The key feature about these methods is that they are called automatically. Whenever the related event occurs, the related C++ code (e.g. the game code or the GUI system) calls the appropriate event handler.

Contrary to "normal" methods, none of these methods is predefined by or pre-implemented, and you normally don't call these methods yourself (although you can). Instead, with these methods, the roles are reversed: If you're interested in handling a specific event, define (write) the related event handler method.

The C++ code (the game code, the GUI system, etc.) will call it when the related event occurs, using the appropriate function parameters for the event (this is similar to overriding virtual methods in C++). Your own implementation code then determines how the event is handled.

The "Event Handlers (Callbacks)" documentation of a class lists and describes all callback methods that are available, but you have to provide an implementation only if you wish to handle the related event. Methods for events that you are not interested in need not be implemented at all.

Classes that have callback methods include (list may be incomplete!):