Programming Guide |
Gets information about the mouse's current state
int sm_ms_inquire(int request);
request
- Specifies the data to get, one of the following constants:
MOUSE_LINE
- The line of the physical display on which the mouse click occurred.
MOUSE_COLM
- The column of the physical display on which the mouse click occurred.
MOUSE_SHIFT
- The state of the Shift, Control, and Alt keys during the mouse click. Panther returns this information in an integer bit mask. For bit settings, refer to the Description.
MOUSE_BUTTONS
- The state of all mouse buttons, left, middle, and right. Panther returns this information in an integer bit mask. For states that are recognized by Panther and their corresponding bit settings, refer to the Description.
MOUSE_FIELD
- The number of the field in which the mouse click occurred. If the mouse click occurs outside a field, the function returns -1.
MOUSE_FORM_LINE
- The number of the Panther screen line on which the mouse click occurred.
MOUSE_FORM_COLM
- The number of the Panther screen column on which the mouse click occurred.
- · The data specified by
request
.
sm_ms_inquire
gets information about the mouse's current state—the position of the last mouse click on the physical or Panther screen, whether other keys are pressed in combination with it, and which mouse buttons have been pressed and how recently.This function's returns an integer value whose bits are set according to the supplied argument,
MOUSE_SHIFT
orMOUSE_BUTTONS
.
MOUSE_SHIFT
sets the three lowest-order bits in the return value to indicate which of three keys—Shift, Ctrl, and Alt—are pressed at the same time as the mouse click.sm_ms_inquire
can set these bits as follows, from lowest- to highest-order bit:
- 1 Shift key is down
For example, a return value of 2 (
0 1 0
) indicates that the Ctrl key is down, while a return value of 5 (1 0 1
) indicates that the Alt and Shift keys are both down. The second of these returns can be represented as follows:
MOUSE_BUTTONS
sets nine bits to indicate the state of the left, right, and middle mouse buttons.sm_ms_inquire
puts the requested data in three segments of three bits each, where each segment represents one of three mouse buttons—left, right, and middle. The three lowest-order bits contain left button data; if the mouse has only one button, only these bit settings are significant. The three middle bits contain right button data, and the three highest-order bits contain data for the middle button, if any.Each bit within a three-bit segment can be set as follows, from lowest- to highest-order bit:
- 0/1 Up/down
For example, the bit settings returned for a just-initiated point and click operation—left button is down and just pressed—can be represented as follows:
A click and drag operation that is in progress—right button is down—can be represented like this:
Only four combinations of bit settings are meaningful to Panther and recognized as valid button states:
/*find out whether any button is down */
int is_any_button_down(void)
{
int retval;
retval = -1;
if (sm_ms_inquire(MOUSE_BUTTONS) > -1)
return retval & 0x49;
return retval;
}