These two events give you access to each of the components of a click. MouseDown fires when the user presses a mouse button, and MouseUp fires when the user releases the button. These even respond to up to three different mouse buttons and can tell you whether you're pressing any of the modifier keys (Shift, Ctrl, Alt) at the same time.
PROCEDURE oObject.MouseDown | oObject.MouseUp
LPARAMETERS [ nIndex , ] nButton, nKeys, nXCoord, nYCoord|
Parameter |
Value |
Meaning |
|
nIndex |
Numeric |
The member of a control array that fired the event. |
|
Omitted |
The control is not in a control array. |
|
|
nButton |
1 |
Left button |
|
2 |
Right button |
|
|
4 |
Center button |
|
|
nKeys |
0 |
No modifiers pressed |
|
1 |
Shift key pressed |
|
|
2 |
Ctrl key pressed |
|
|
3 |
Shift and Ctrl keys pressed |
|
|
4 |
Alt key pressed |
|
|
5 |
Shift and Alt keys pressed |
|
|
6 |
Ctrl and Alt keys pressed |
|
|
7 |
Shift, Ctrl and Alt keys pressed |
|
|
nXCoord, nYCoord |
Numeric |
The coordinates of the mouse location in the form's ScaleMode. |
MouseDown and MouseUp give you a chance to do something before a Click, RightClick, MiddleClick or DblClick actually occurs. In fact, putting NoDefault in these events can prevent clicks. See Click for more on that—there are some problems.
We're not sure why FoxPro can't detect pressing multiple buttons (like left and right together), but we're delighted by the fact that the right mouse button and even the middle button are full players here.
When the middle button is really a wheel, the MouseUp for it may not fire when you first release. This happens when you're on a control that interprets clicking the wheel as a signal to begin scrolling. In that case, MouseUp doesn't fire until you click the wheel again. At that time, MouseUp fires, then MouseDown and MouseUp fire again. If you click one of the other buttons instead, the MouseUp that matches the initial MouseDown never fires.
You may have different keys pressed when MouseDown fires than when the corresponding MouseUp is executed. However, except in very weird circumstances (such as having a WAIT WINDOW without NOWAIT in a MouseDown event), you always get MouseUp for the same object that fired MouseDown, even if you've moved the mouse in between. However, nXCoord and nYCoord reflect the true position of the mouse at the time the button goes down or comes up, so you can test whether you're still over the same object. (Dragging the mouse off the control between MouseDown and MouseUp does prevent that control's Click from firing.)
* MouseDown is a good place to initiate drag-and-drop.
This.Drag(1)AMouseObj(), Click, DblClick, Drag, DragDrop, MiddleClick, MouseMove, RightClick
