MouseMove

Have you ever wanted to do something just because the mouse moved over a particular point on the screen? We have (although providing tooltips, the thing we've most wanted to do, is built into Visual FoxPro). MouseMove is the key to reacting to the rodent's movements.

Usage

PROCEDURE oObject.MouseMove
LPARAMETERS [ nIndex , ] nButtons, nKeys, nXCoord, nYCoord
As with the other control events, we have the same, old, nearly useless, optional nIndex parameter. It's for the rare occasions when you use a control array.The other parameters are neat. They tell you which mouse buttons and which modifier keys (Shift, Ctrl, Alt) are pressed as the mouse moves along. The last two tell you where you are. You can use the parameters to figure out how to respond to the mouse movement.

Example

PROCEDURE MouseMove
* Tell the user what's going on.
LPARAMETERS nButton, nShift, nXCoord, nYCoord
 
DO CASE
CASE nButton = 0
   cButton = "No buttons"
CASE nButton = 1
   cButton = "Left"
CASE nButton = 2
   cButton = "Right"
CASE nButton = 3
   cButton = "Left and Right"
CASE nButton = 4
   cButton = "Center"
CASE nButton = 5
   cButton = "Left and Center"
CASE nButton = 6
   cButton = "Center and Right"
CASE nButton = 7
   cButton = "All three"
OTHERWISE
   cButton = "That's odd!"
ENDCASE
 
DO CASE
CASE nShift = 0
   cShift = "No keys"
CASE nShift = 1
   cShift = "Shift"
CASE nShift = 2
   cShift = "Ctrl"
CASE nShift = 3
   cShift = "Shift+Ctrl"
CASE nShift = 4
   cShift = "Alt"
CASE nShift = 5
   cShift = "Shift+Alt"
CASE nShift = 6
   cShift = "Ctrl+Alt"
CASE nShift = 7
   cShift = "All three"
OTHERWISE
   cShift = "That's odd!"
ENDCASE
 
DEBUGOUT "Moving over " + This.Name + ;
         " at " + LTRIM(STR(nXCoord)) + "," + ;
         LTRIM(STR(nYCoord)) + " with " + ;
         cButton + ", " + cShift NOWAIT
 
* A shorter, but less readable, way to test for the different
* conditions is to use BitTest as follows:
lLeft = BitTest(nButton,0)
lRight = BitTest(nButton,1)
lCenter = BitTest(nButton,2)
lShift = BitTest(nShift,0)
lCtrl = BitTest(nShift,1)
lAlt = BitTest(nShift,2)
As with the other mouse events that pass the nKeys parameter, you can't reliably detect nKeys=7 (Ctrl+Alt+Shift) unless you've set OUTSHOW=OFF in your Config.FPW file. (We've seen some cases where you can detect it temporarily, but then the form stops responding until you release at least one key.)

See Also

Click, DblClick, DragOver, Mouse, MouseDown, MouseEnter, MouseLeave, MousePointer, MouseUp, MouseWheel


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .