Getpoint Function Example

Details

Action

A MathScript Function: If no argument is supplied, i.e. Getpoint(), it returns a two element vector (VECTOR #2) of the coordinates of a single point at the location of the cursor in a 2D graph window when the left mouse button is clicked on and off. If the argument False is supplied, i.e. Getpoint(False), it returns a two element vector (VECTOR #2) of the coordinates of a single point at the location of the cursor in a 2D graph window when the left mouse button is clicked on, or the mouse is moved. If the left mouse button is double-clicked, or the right mouse button is clicked on and off, the Empty List (False) is returned instead of a vector.

make posvec getpoint()
Creates a variable posvec containing a vector of the coordinates of the selected point.

The following command causes a sprite to follow the mouse, discretely while the left mouse button is clicked, or continuously while it is held down. It terminates only when the left mouse button is doubleclicked, or the right mouse button is clicked.

command dragsprite (st spr) {

showsprite spr;

do

(ve #0 pt) := getpoint(False)

until pt==false

{

movesprite spr to pt;

pt := getpoint(False);

}

}