The inrectangle( function checks to see if a point is inside a rectangle.


This function has two parameters:

point – is the point to test.

rectangle – is the rectangle to test.


This function checks to see if a point is inside a rectangle (see Graphic Coordinates. The function returns a true or false result – if the point is inside the rectangle, the function returns true (–1). If the point is not inside the rectangle, the function returns false (0). The point and the rectangle may be in screen, window, or form relative co-ordinates as long as you make sure both use the same co-ordinate system.

Here is a silly example that times how long it takes the user to move the mouse away from a button.

local startTime
while inRectangle(info("mouse"),info("buttonrectangle"))
message pattern( now()-startTime,"# second~")

As long as the mouse is over the button, the procedure will whirl around and around doing nothing (remember, the nop statement does no operation). When the mouse moves away from the button, the inRectangle( function goes false and the loop is broken.

See Also


10.0UpdatedUnlike Panorama 6 and earlier, the parameters to this function are floating point values instead of integers (it will also accept integers). Also, the rectangle used by this function is a 32 byte binary value, instead of an 8 byte text value.