Command
Not Applicable
Description
Mouse Position X reports the location of the mouse with respect to a Form's coordinate system. It ia often used for on-screen joysticks or for identifying a coordinate on a graph.
Mouse positions are only known during the mouse events Mouse Down, Mouse Drag, and Mouse Up.
Escapes
Referencing Mouse Position X does not produce any escapes.
Examples
This example shows an axis moving to an indicated position on a form based on a mouse click:
... producing this:
If it was desired to "snap" to a grid location and not permit moving to positions in between grids this change could be made:
Perhaps the use wants to change the destination on the fly. The way to do this is to use the non-blocking move command Begin Move To permitting another mouse event to occur before the move is finished:
If a click is made, and then a further click is made, the motion will blend to the new destination without stopping at the first. However a new kind of problem can occur.
If the new target is behind the current motion rather than still ahead this re-targeting cannot be done. In this case a Motion Overrun Escape Code is generated:
The desired behavior would be to abandon the no longer desired original target by stopping early and heading towards the new target. This is done as show below with a Try Recover block:
Related Topics
Mouse Down
Mouse Drag
Mouse Up
Mouse Position Y
Set Coordinate Frame