By using mouse rectangles, you can specify how a gauge will interact with the mouse pointer (mouse movement and mouse button clicks). For example, you can change the cursor or display a ToolTip as the mouse enters the area you've defined as a mouse rectangle; you can also trigger a Flight Simulator event or execute a callback function.
To define a mouse rectangle you use a combination of the mouse definition macros, as shown in the following code example:
MOUSE_PARENT_BEGIN(x, y, w, h, helpid)
MOUSE_PARENT_END
MOUSE_PARENT_BEGIN uses the following parameters:
Parameter | Description |
x, y | Specifies the upper-left corner of the rectangle. |
w, h | Specifies the width and height of rectangle. |
helpid | Specifies the Help ID of the ToolTip text to display for the rectangle. For foreign versions, the Help IDs point to localized strings. There is currently no way to add more ToolTip ID’s. For a complete list of Help IDs, see the topic, Help IDs. |
MOUSE_CHILD_EVENT defines a sub-rectangle of the rectangle created by MOUSE_PARENT_BEGIN; you can use the MOUSE_CHILD_FUNCT macro to specify a function to be called when an event specified by the mouse_flags parameter is triggered.
MOUSE_CHILD_EVENT(x, y, w, h, cursor, mouse_flags, event_id)
MOUSE_CHILD_EVENT uses the following parameters:
Parameter | Description |
x, y | Specifies the upper-left corner of the rectangle. |
w, h | Specifies the width and height of rectangle. |
cursor | Specifies the cursor shown when the mouse is in the mouse rectangle. This parameter can be set to one of the following: CURSOR_NONE CURSOR_NORMAL CURSOR_UPARROW CURSOR_DOWNARROW CURSOR_LEFTARROW CURSOR_RIGHTARROW CURSOR_HAND CURSOR_CROSSHAIR |
mouse_flags | Specifies under what conditions a callback function will be executed. It can be set to one of the following values: MOUSE_NONE MOUSE_RIGHTSINGLE MOUSE_MIDDLESINGLE MOUSE_LEFTSINGLE MOUSE_RIGHTDOUBLE MOUSE_MIDDLEDOUBLE MOUSE_LEFTDOUBLE MOUSE_RIGHTDRAG MOUSE_MIDDLEDRAG MOUSE_LEFTDRAG MOUSE_MOVE MOUSE_DOWN_REPEAT MOUSE_KEYBOARD |
event_id | Specifies the event to be sent to Flight Simulator 98 by the mouse event. For a complete list of events, see the topic Event IDs. |
The MOUSE_CHILD_FUNCT macro calls a callback function when an event specified by the mouse_flags parameter is triggered. The callback function is defined as follows:
BOOL mouse_child_funct(PPIXPOINT relative_point, FLAGS32 mouse_flags)
For more information, see the topic mouse_child_funct.
The trigger_key_event and panel_window_toggle APIs are often used in the mouse event callback functions. For more information, see the topics panel_window_toggle and trigger_key_event.
The syntax for MOUSE_CHILD_FUNCT is as follows:
MOUSE_CHILD_FUNCT(x, y, w, h, cursor, mouse_flags, function)
MOUSE_CHILD_FUNCT uses the following parameters:
Parameter | Description |
x, y | Specifies the upper-left corner of the rectangle. |
w, h | Specifies the width and height of rectangle. |
cursor | Specifies the cursor shown when the mouse is in the mouse rectangle. It can be set to one of the following: CURSOR_NONE CURSOR_NORMAL CURSOR_UPARROW CURSOR_DOWNARROW CURSOR_LEFTARROW CURSOR_RIGHTARROW CURSOR_HAND CURSOR_CROSSHAIR |
mouse_flags | Specifies under what conditions the callback function will be executed. MOUSE_NONE MOUSE_RIGHTSINGLE MOUSE_MIDDLESINGLE MOUSE_LEFTSINGLE MOUSE_RIGHTDOUBLE MOUSE_MIDDLEDOUBLE MOUSE_LEFTDOUBLE MOUSE_RIGHTDRAG MOUSE_MIDDLEDRAG MOUSE_LEFTDRAG MOUSE_MOVE MOUSE_DOWN_REPEAT MOUSE_KEYBOARD |
function | Specifies the callback function executed by the mouse event. |
The following is an example of mouse rectangle setup code:
MOUSE_BEGIN(mouse_rect, HELPID_B737_FLAPS, 0, 0)
MOUSE_CHILD_EVENT(0,0,44,85, CURSOR_DOWNARROW, MOUSE_LEFTSINGLE, KEY_FLAPS_DECR)
MOUSE_CHILD_EVENT(44,0,44,85, CURSOR_UPARROW, MOUSE_LEFTSINGLE, KEY_FLAPS_INCR)
MOUSE_END
If you want to use mouse rectangles, you must use the mouse rectangle Panel API calls. These APIs set up the mouse rectangles to be used by the Panel system.
Call the mouse_list_install and mouse_list_register APIs in the install_routine gauge interface function, as shown in the following code example:
void install_routine(HINSTANCE resource_file_handle)
{
element_list_install(list, resource_file_handle);
mouse_list_install(mouse_rect, &gauge_header, &background.image_data.final->dim );
mouse_list_register(mouse_rect, &gauge_header);
}
Call the mouse_list_unregister API in the kill_routine gauge interface function, as shown in the following code example:
void kill_routine()
{
mouse_list_unregister(mouse_rect, &gauge_header);
element_list_kill(list);
}