_TITLE "press menu number key or Double Click Menu Item" 'b+ 2020-02-17 with TerryRitchie mouse code x
AS INTEGER ' actual Y location of mouse cursor y
AS INTEGER ' actual X location of mouse cursor Click
AS INTEGER ' TRUE if single click occurred DoubleClick
AS INTEGER ' TRUE if double click occurred LeftDown
AS INTEGER ' TRUE if left button is down
'SCREEN _NEWIMAGE(640, 480, 32) '<<<<<<<<<<<<<< i'm thinking mouse sub should work in any screen including default
PRINT "Press menu # key or double click menu item:" PRINT ms$;
") Menu item "; ms$
PRINT "9) Quit this demo"
UpdateMouse
'IF Mouse.DoubleClick THEN SOUND 880, 1
'IF Mouse.Click THEN SOUND 440, 1
'PRINT "Mouse X : "; Mouse.x
'PRINT "Mouse Y : "; Mouse.y
'PRINT "Last click X: "; Mouse.ClickX
'PRINT "Last click Y: "; Mouse.ClickY
'PRINT "Left button is ";
'IF Mouse.LeftDown THEN PRINT "DOWN" ELSE PRINT "UP"
IF keyhit
> 0 THEN oldkeyhit
= keyhit
IF ink$
<> "" THEN oldink$
= ink$
'PRINT "Last KeyHit = "; oldkeyhit
'PRINT "Last Inkey$ = "; oldink$
'IF Mouse.LeftDown THEN
'LINE (Mouse.ClickX, Mouse.ClickY)-(Mouse.x, Mouse.y), _RGB32(0, 0, 255), BF
'END IF
LOCATE 15, 1:
PRINT "Mouse x, y:"; Mouse.x;
","; Mouse.y
IF Mouse.DoubleClick
AND Mouse.ClickY
= m
+ 1 OR ink$
= _TRIM$(STR$(m
)) THEN 'for screen 0 or default my = line number
' Demo use single click info when doesn't interfere with dbl click evaluation, ie doesn't delay 2nd click detection
IF Mouse.Click
AND (Mouse.ClickY
> 10) THEN PRINT " You clicked outside then menu area: col"; Mouse.ClickX;
", row"; Mouse.ClickY
PRINT "You pressed "; ink$
'_DISPLAY
Mouse.x
= _MOUSEX ' actual X coordinate Mouse.y
= _MOUSEY ' actual Y coordinate Mouse.DoubleClick = FALSE
Mouse.Click = FALSE
CASE TRUE
' button is down IF NOT Mouse.LeftDown
THEN ' already held down? Mouse.LeftDown = TRUE ' no, remember that it is now
IF Mouse.DCTimer
THEN ' was last click less than double click timer value? IF ABS(Mouse.ClickX
- Mouse.x
) < 3 AND ABS(Mouse.ClickY
- Mouse.y
) < 3 THEN Mouse.DoubleClick = TRUE ' yes, report a double click happened
Mouse.DCTimer = 0 ' reset the double click timer
ELSE ' no, double click timer has run out Mouse.DCTimer = FPS \ 3 ' reset double click timer to 1/3 second
Mouse.ClickX = Mouse.x ' remember X location of click
Mouse.ClickY = Mouse.y ' remember Y location of click
Mouse.Click = TRUE ' report that a single click occurred
CASE FALSE
' button is up IF Mouse.LeftDown
THEN ' was the left button previously down? Mouse.LeftDown = FALSE ' yes, report that it's now up
IF Mouse.DCTimer
THEN ' time left in double click timer? Mouse.DCTimer = Mouse.DCTimer - 1 ' yes, decrement value