C4 Engine
C4 Engine API Documentation

Widget::HandleMouseEvent

Defined in:  C4Widgets.h
Called when the user interacts with a widget using the mouse.
Prototype

virtual void HandleMouseEvent(const PanelMouseEventData *eventData);

Parameters
eventData A pointer to the event data.
Description
The HandleMouseEvent function should be overridden by subclasses of the Widget class that need to respond to mouse interaction from the user. This function is called by the Interface Manager when the user uses the mouse inside the widget's bounding box and the value returned by the widget's Widget::TestPosition function is not kWidgetPartNone.

The eventType field of the PanelMouseEventData structure can be one of the following constants.
kEventMouseDown The user pressed the primary mouse button.
kEventMouseUp The user released the primary mouse button.
kEventRightMouseDown The user pressed the right or secondary mouse button.
kEventRightMouseUp The user released the right or secondary mouse button.
kEventMiddleMouseDown The user pressed the middle or tertiary mouse button.
kEventMiddleMouseUp The user released the middle or tertiary mouse button.
kEventMouseMoved The user moved the mouse while one of the buttons is still pressed.
kEventMouseWheel The user moved the mouse wheel.
The mousePosition field of the PanelMouseEventData structure contains the position of the mouse in the local coordinate system of the widget. (The z component of the position is always zero.)

After one of the mouse down events has been received, the Interface Manager sends the kEventMouseMoved event to the HandleMouseEvent function any time the mouse is actually moved until the button is released, at which time a corresponding mouse up event is sent. Additionally, while a mouse button is down, the Interface Manager calls the Widget::TrackTask function once per frame regardless of whether the mouse has moved.

The kEventMouseWheel event is only received if the kWidgetMouseWheel usage flag has been set by the widget subclass implementation through a call to the Widget::SetWidgetUsage function. For a mouse wheel event, the y component of the wheelDelta field of the PanelMouseEventData structure contains a positive or negative movement value, and the x component is always zero.
See Also

Widget::TestPosition

Widget::HandleKeyboardEvent

Widget::PostWidgetEvent

Widget::GetWidgetUsage

Widget::SetWidgetUsage

PanelMouseEventData