Need help with touch screen.
Root / Programming Questions / [.]
thatguyCreated:
TOUCH OUT STTM,TX,TY will give the coordinates of the touch in variables TX and TY, and the number of frames the screen has been touched in STTM. If STTM is 0, that means the screen isn't being touched at all, and TX and TY will be the coordinates of the last touch instead.
This program will give you a basic idea of how it works:
ACLS XSCREEN 2 WHILE TRUE VSYNC TOUCH OUT STTM,TX,TY CLS ?STTM,TX,TY WENDP.S. This actually works even in screen modes that have the keyboard on the touch screen. It's not all that useful, but you could use it to detect when someone's trying to press some of the keys that normally do nothing when a program is running, like Copy, Paste, Undo, and so on, since those can't be detected with INKEY$().
well, how do you specify an area?You don't; you have to check whether the coordinates are in an area manually. That said, you could put together something like this:
ACLS XSCREEN 2 DISPLAY 1 WHILE TRUE VSYNC GCLS IF TOUCHED(50,50,100,100) THEN GFILL 50,50,100,100,#GREEN ELSE GBOX 50,50,100,100,#GREEN ENDIF WEND DEF IN(N,L,H) RETURN N>=L && N<=H END DEF TOUCHED(X0,Y0,X1,Y1) TOUCH OUT STTM,TX,TY RETURN STTM && IN(TX,X0,X1) && IN(TY,Y0,Y1) END