C4 Engine Terathon Software C4 Engine API Documentation

• System Utilities

API Links
Developer Links

class MouseEventHandler

Defined in:  C4Engine.h
The MouseEventHandler class encapsulates a mouse event handler function.
Definition

class MouseEventHandler : public ListElement<MouseEventHandler>

Constructor

MouseEventHandler(HandlerProc *proc, void *cookie = nullptr);

Parameters
proc The procedure 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 procedure 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 procedures corresponding to all installed mouse event handlers are invoked. The HandlerProc type is defined as follows.

typedef bool HandlerProc(const MouseEventData *eventData, void *cookie);

The eventType field of the MouseEventData structure specifies what type of mouse event occurred and can be one of the following values.
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.
kEventMultiaxisMouseTranslation The translation rate changed for a multiaxis mouse device.
kEventMultiaxisMouseRotation The rotation rate changed for a multiaxis mouse device.
kEventMultiaxisMouseButtonState The button state changed for a multiaxis mouse device.
For mouse down, mouse up, and mouse moved events, the mousePosition field of the MouseEventData structure specifies the screen coordinates at which the mouse event occurred. For the kEventMouseWheel event, the y member of the mousePosition field specifies how far the wheel was moved (positive or negative), and the x member is undefined.

For the kEventMultiaxisMouseTranslation and kEventMultiaxisMouseRotation events, the mousePosition field contains the 3D translation or rotation rate information. For the kEventMultiaxisMouseButtonState event, the eventFlags field of the MouseEventData structure contains the state of all 32 possible buttons, with the lowest bit representing button 1 and the highest bit representing button 32.

The cookie parameter is the value passed to the MouseEventHandler constructor.

The value returned by the handler specifies whether the mouse event was successfully handled. If the handler returns true, then the mouse event is considered handled, and no further mouse event handlers will be called for the same event. If the handler 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.