MouseDown Event
Object List Next Object
Defined By: ButtonGadget
Description:
Occurs when the user presses any mouse button. Often used with the
corresponding MouseUp event to define what occurs when a mouse button is pressed and
released.
Usage:
Sub MouseDown(button As Integer, shift As Integer, x As Single, y As Single)
Syntax Description
button The button was pressed to trigger the event. The button argument sets bits that
correspond to the following values: 1 for the left button, 2 for the right button, and
4 for the middle button. Only one bit is set at a time.
shift The status of the SHIFT, CTRL, and ALT keys when the specified button was pressed. Each of these keys has a corresponding bit-flag value. SHIFT has
a value of 1, CTRL is 2, and ALT is 4. To indicate which key or keys were
pressed, the key values are summed in the Shift argument. For example, if both CTRL and ALT are pressed, the value of Shift is 6.
x, y The x and y coordinates defining the current location of the mouse pointer. x and y are single-precision variables that use the coordinate system established by
the object's ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties.
Details:
The arguments included in the MouseDown event allow you to indicate the status
of the mouse at the time the event is called. In addition to using a MouseDown
procedure to determine that a mouse button has simply been pressed, you can
also determine which mouse button was pressed, and what combination of the SHIFT,
ALT, or CTRL keys were being pressed, if any. You can also specify different
actions that you would like to occur based on which mouse button is pressed.
MouseDown events allow you to distinguish between the left, right, and middle
mouse buttons; the Click and DblClick events do not. When a mouse button is
pressed while the pointer is over a form or control, that object essentially owns
the mouse and receives all mouse events until the MouseUp event is processed.
If the mouse pointer leaves the area of the form or object before the MouseUp
event is processed, the x, y mouse-pointer coordinates received could be from
outside of the receiving form or control.
If a series of mouse buttons are pressed, the object that receives the second
mouse action (the action after the first mouse click) will own all subsequent
mouse events until all buttons are released.
To test for the button or shift arguments you can use logical operators. The virtual constants you can use to
test for various combinations of buttons are listed as follows:
Constant Value
LEFT_BUTTON 1
RIGHT_BUTTON 2
MIDDLE_BUTTON 4
SHIFT_MASK 1
CTRL_MASK 2
ALT_MAST 4
When using a MouseMove procedure, please note that the button argument indicates the current state of all buttons; whereas, the button argument for MouseDown indicates only one button for each event. MouseMove
procedures are often used to react to events generated by moving the mouse.
See Also:
Click event, MouseMove event, MouseUp event