GLBasic forum

Main forum => GLBasic - en => Topic started by: gregbug on 2009-Dec-21

Title: MouseState ... Flush
Post by: gregbug on 2009-Dec-21
is there a way to flush MouseState (only mouse button1 and button 2) ?  :blink:

thanks.
Title: Re: MouseState ... Flush
Post by: Schranz0r on 2009-Dec-21
No, you have to write a function for mousehit
Title: Re: MouseState ... Flush
Post by: gregbug on 2009-Dec-21
ah ok!

thanks!

Title: Re: MouseState ... Flush
Post by: FutureCow on 2009-Dec-22
Here's my function in case it helps.

Do a "GOSUB MouseUpdate" in your main code. You can then query the mouse location (MX/MY) or Button status (MB1/MB2).
This subroutine ensures you only get one click regardless of how long the user holds the mouse button down for.

Code (glbasic) Select

GLOBAL MX, MY, MB1, MB2, PreviousMouseButton1State, PreviousMouseButton2State

SUB MouseUpdate:
LOCAL MBTemp%, MB2Temp%

MOUSESTATE MX, MY, MBTemp, MB2Temp
IF MBTemp = 1
IF PreviousMouseButton1State = 1
MB1 = 0
ELSE
MB1 = 1
PreviousMouseButton1State = 1
ENDIF
ELSE
MB1 = 0
PreviousMouseButton1State = 0
ENDIF


IF MB2Temp = 1
IF PreviousMouseButton2State = 1
MB2 = 0
ELSE
MB2 = 1
PreviousMouseButton2State = 1
ENDIF
ELSE
MB2 = 0
PreviousMouseButton2State = 0
ENDIF

ENDSUB // MOUSEUPDATE
Title: Re: MouseState ... Flush
Post by: gregbug on 2009-Dec-22
Thanks for your code FutureCow!  =D