Mouse Command

Purpose

Returns the current X and Y coordinates of the mouse pointer, the status of the mouse buttons and (optionally) the status of the keyboard shift keys (KB shift).

Syntax

Mouse mx%, my%, mk% [, kb%]

mx%, my%, mk%, kb%:ivar

Description

The Mouse command is a combination of GFA-BASIC functions MouseX, MouseY, MouseK, and MouseKB. In addition, by supplying the fourth optional parameter the status of the keyboard shift keys can also be interrogated.

Example

OpenW 1

Local a$, ak%, ax%, ay%, mk%

Local b%, mx%, my%, t$, title$, ab%

Do

t$ = InKey$

// to end press ESC

Exit Do If Asc(t$) = 27

title$ = "X-direction" + Space(10)

title$ = title$ + "Y-direction"

title$ = title$ + Space(10)

title$ = title$ + "Mouse Key" + Space(10)

title$ = title$ + "Shift-Key"

Text 8, 16, title$

ax% = mx%, ay% = my%, ak% = mk%, ab% = b%

Mouse mx%, my%, mk%, b%

// only new, if something will change

If (ax% <> mx%) || (ay% <> my%) _

|| (ak% <> mk%) || (ab% <> b%)

// delete a line

Text 8, 46, Space$(999)

a$ = Str$(mx%, 4, 0) + Space(25)

a$ = a$ + Str$(my%, 4, 0) + Space(20)

a$ = a$ + Str$(mk%, 8, 0) + Space(20)

a$ = a$ + Str$(b%)

Text 8, 46, a$

EndIf

Loop

CloseW 1

See Also

DefMouse, MouseK, MouseKB, MouseX

{Created by Sjouke Hamstra; Last updated: 18/10/2014 by James Gaite}