GLBasic forum

Codesnippets => Code Snippets => Topic started by: ampos on 2010-Oct-08

Title: Iphone mouse with double-click
Post by: ampos on 2010-Oct-08
Use this if you want to read iPhone screen touch or want to emulate iphone screen on desktop PC.

Code (glbasic) Select

TYPE Mouse
   x
   y
   b1
   b2
   bl
ENDTYPE

GLOBAL mouse AS Mouse

SUB imouse:
MOUSESTATE mx,my,b1,b2

IF b1=0 AND mouse.b1<>0 THEN mouse.bl=0

IF b1=0
mouse.b1=0
INC mouse.bl
ENDIF

IF b1=1
mouse.x=mx
mouse.y=my
IF mouse.bl<10
mouse.b1=2
ELSE
mouse.b1=1
ENDIF
ENDIF

ENDSUB


This function will return:

mouse.x = x coord
mouse.y = y coord
mouse.b1 = 1 = left single click
mouse.b1 = 2 = left double click
mouse.b2 = 1 = right single click

mouse.x & mouse.y will return the last known mouse coordinates (the ones where you clicked)

In the line
   IF mouse.bl<10
you can change the 10 number for faster/slower double click delay

Thanks to backslider for the original one.