class MouseEventHandler
Defined in:
The C4Engine.hMouseEventHandler class encapsulates a mouse event handler callback function.
Definition
class MouseEventHandler : public ListElement<MouseEventHandler>
Constructor
MouseEventHandler(HandlerCallback *callback, void *cookie = nullptr);
Parameters
callback |
The callback function to invoke when a mouse event occurs. |
cookie |
The cookie that is passed to the event handler as its last parameter. |
Description
The MouseEventHandler class encapsulates a callback function that is invoked when a mouse event occurs. Once an instance of the MouseEventHandler class has been constructed, it can be installed by calling the Engine::InstallMouseEventHandler function.When a mouse event occurs, the callback functions corresponding to all installed mouse event handlers are invoked. The
HandlerCallback type is defined as follows.
typedef bool HandlerCallback(const MouseEventData *eventData, void *cookie);
eventType field of the MouseEventData structure specifies what type of mouse event occurred and can be one of the following constants.
kEventMouseDown |
The left mouse button was pressed. |
kEventMouseUp |
The left mouse button was released. |
kEventRightMouseDown |
The right mouse button was pressed. |
kEventRightMouseUp |
The right mouse button was released. |
kEventMiddleMouseDown |
The middle mouse button was pressed. |
kEventMiddleMouseUp |
The middle mouse button was released. |
kEventMouseMoved |
The mouse location was moved. |
kEventMouseWheel |
The mouse wheel was moved. |
mousePosition field of the MouseEventData structure specifies the screen coordinates at which the mouse event occurred. For the kEventMouseWheel event, the wheelDelta member specifies how far the wheel was moved in the x and y directions. (Currently, the x delta is always zero.)The
cookie parameter is the value passed to the MouseEventHandler constructor.The value returned by the callback function specifies whether the mouse event was successfully handled. If the callback function returns
true, then the mouse event is considered handled, and no further mouse event handlers will be called for the same event. If the callback function returns false, then the event is passed to the next mouse event handler.A mouse event handler is uninstalled by destroying its associated class instance.
Base Classes
ListElement<MouseEventHandler> |
Used internally to store all instances of MouseEventHandler in a list.
|
