int TouchAdd(int x, int y, int width, int height, int (*callback)(int id, int event, int x, int y), int id);
Add a touch area not associated with a view.
Return Value
Returns an int handle to the touch area.
Parameters
x X coordinate.
y Y coordinate.
width Touch area width.
height Touch area height.
callback Specifies a function that will be called when the touch area is touched.
int OnBall(int id, int event, int x, int y) //event: 1=down, 2=move, 3=up { if (event == 3) {// touch up (touched and released) //...do something } return 0; }
id Touch id to be sent to callback.
Remarks
The TouchAdd() function specifies a touch area not associated with an image. There is a ViewAdd() function with a built-in touch area and a callback for a touch related to an image.
Availability
Available in DragonFireSDK 1.0 and later.
Example
Description: This example will set up a touch area from 0, 0 to 100, 100.
#include "DragonFireSDK.h"
int OnTouchArea(int id, int event, int x, int y);
void AppMain() { TouchAdd(0, 0, 100, 100, OnTouchArea, 0); }
int OnTouchArea(int id, int event, int x, int y) //event: 1=down, 2=move, 3=up { if (event == 3) { // touch up (touched and released) //...do something printf("You touched the touch area\n"); return 0; } }
void AppExit() {
}
void OnTimer() {
} |