FUNCTIONS CORE

NumButtons()

Return the number of mouse buttons

Syntax

Signature
NumButtons( ) --> nButtonCount

Arguments

None.

Return value

The number of buttons the GT reports, 0 without a mouse.

Description

NumButtons() asks the GT, for example before the program offers an action on the right button.

Notes

NumButtons() needs a GT.

Example

NumButtons.prg
#if OS_LINUX
   REQUEST GTXWC
#else
   REQUEST GTWVT
#endif

PROCEDURE Main()

   LOCAL nButtons := NumButtons()

   Check( 'NumButtons() is a number         ', ValType( nButtons ), "N" )
   Check( 'NumButtons() is not negative     ', nButtons >= 0, .T. )

   QOut( "" )
   QOut( "The mouse has " + LTrim( Str( nButtons ) ) + " buttons" )
   QOut( "Any key or 10 seconds ends the program" )
   Inkey( 10 )

RETURN

STATIC PROCEDURE Check( cTitle, xResult, xExpected )

   QOut( cTitle + IIF( xResult == xExpected, "OK", "ERROR" ) )

RETURN

Output

NumButtons() is a number         OK
NumButtons() is not negative     OK

See also