Equinox Online Help - Language Reference - A to Z

Home

MousePosition

Applies to
SyntaxMousePosition [XItem][, YItem][, WidthItem][, HeightItem][, ObjectExpression]
Action[Statement] Returns the current coordinates (in screen pixels) of the mouse cursor.
ScopeOnly usable in form methods.
Notes

This statement determines the current screen coordinates (in pixels) of the mouse cursor. XItem and YItem are the names of two fields, variables, or workareas, into which the coordinates are returned.

You can use the optional argument, ObjectExpression, to specify the object name of an object on the form. The statement then returns the position of the cursor within that object. The size of the object (in pixels) is returned in WidthItem and HeightItem.

If the cursor is not within the specified object then the coordinates -1, -1 are returned. If an error occurs, an error number is stored in the system workarea SysError.

CategoryMenus and mouse
See Also EnableCommand, MouseObject, MouseObjectName, Trigger
Example

The following example divides a picture into sixteen parts. Text is displayed on the status line, describing the cell currently containing the mouse cursor.

number x(4, 0), y(4, 0), PicHeight, PicWidth

MousePosition x, y, PicWidth, PicHeight, "Pict"

switch Int((y * 4 / PicHeight) * 4 + (x * 4 / PicWidth))
case 5, 9
StatusLine "See John"
case 6, 10
StatusLine "See Mary"
case 11
StatusLine "See Spot"
end switch