OWBasic Standard Library

Group STD Home INTRO Alphabetical Index

Querying Touch Tables

STD_TCHOBJ%(TCHTBL%[])

This function compares the touch coordinates with the rectangular areas defined in TCHTBL and returns the object code of the area. If no area was touched, the function returns -1.

The touch table entries have to be declared as shown here:
CONST tchtbl=(<objcode>, <touchfunc>, <x1>,<y1>,<x2>,<y2>,
<objcode>, <touchfunc>, <x1>,<y1>,<x2>,<y2>,
...
-1)
If the object code is -2, the acutal element is not queried, if -1, the function returns. Therefore, every touch table has to end with -1.

The function allows the use of up to 8 different touch functions. To install a touch function (touch functions must be of the type func!(x1%,y1%,x2%,y2%)), assign the function to an element of std_tch. std_tch[0] points to TOUCHED! per default.

Example:
CONST tchtbl=(1, 1, 0,0,159,19,
10, 0, 0,20,78,159,
11, 0, 20,159,159,
-1)

std_tch[1]=FUNC(BTNTOUCH!)

DO
SYS 2
CASE SELECT STD_TCHOBJ(tchtbl)
 CASE 1: end 0
 CASE 10: PRINT "left half touched"
 CASE 11: PRINT "right half touched"
ENDCASE
LOOP WHILE TRUE

Gruoup STD Home INTRO Alphabetical Index