C4 Engine
C4 Engine API Documentation

class WindowEventHandler

Defined in:  C4Interface.h
The WindowEventHandler class encapsulates a window event handler function.
Definition

class WindowEventHandler : public ListElement<WindowEventHandler>

Constructor

WindowEventHandler(HandlerCallback *callback, void *cookie = nullptr);

Parameters
callback The callback function to invoke when a window event occurs.
cookie The cookie that is passed to the event handler as its last parameter.
Description
The WindowEventHandler class encapsulates a procedure that is invoked when a window event occurs. Once an instance of the WindowEventHandler class has been constructed, it can be installed by calling the InterfaceMgr::InstallWindowEventHandler function.

When a window event occurs, the callback functions corresponding to all installed window event handlers are invoked. The HandlerCallback type is defined as follows.

typedef void HandlerCallback(const WindowEventData *eventData, void *cookie);

The eventType field of the WindowEventData structure specifies what type of window event occurred and can be one of the following constants.
kEventWindowAdd A window was added to the interface.
kEventWindowRemove A window was removed from the interface.
kEventWindowChange A window's enable state or visibility state was changed.
The eventWindow field of the WindowEventData structure specifies the window for which the event occurred. The cookie parameter is the value passed to the WindowEventHandler constructor.

A window event handler is uninstalled by destroying its associated class instance.
Base Classes
ListElement<WindowEventHandler> Used internally to store all instances of WindowEventHandler in a list.