C

TouchScriptInterface Class

The TouchScriptInterface class enables you to create scripts that emulate touch gestures. More...

Header: #include <TouchScriptInterface>

Public Functions

void beginTouch(int id, int x, int y)
void endTouch(int id, int x, int y)
void updateTouch(int id, int x, int y)

Detailed Description

The TouchScriptInterface class enables you to create scripts that emulate touch gestures.

Touch screens allow users to interact with devices by touching the screen with one or more fingers.You can create scripts that emulate touch gestures, such as tap, pinch, pan, and swipe.

In the scripts, you can either use screen cordinates to indicate touch points, or specify them as relative to the position of the mouse on the screen.

The TouchScriptInterface class is exposed as touch.

For example, the following example script emulates a pan event:

var inX = input.mouseX();
var midX = emulator.displayWidth() / 2;
var startLeft
if (inX < midX)
    startLeft = true
else if (inX > midX)
    startLeft = false
else return

touch.beginTouch(0, inX, 100);
touch.beginTouch(1, inX, 110);
while (1) {
    if (startLeft) {
        if (inX > midX)
            break;
        inX += 10;
    } else {
        if (inX < midX)
            break
        inX -=10;
    }

    touch.updateTouch(0, inX, 100);
    touch.updateTouch(1, inX, 110);
    yield(1);
}
touch.endTouch(0, inX, 100);
touch.endTouch(1, inX, 110);

First, the beginTouch() function is used to specify two touch points with the identifiers 0 and 1 that are relative to the position of the mouse on the screen. Second, the updateTouch() function is used to update the touch points to move the content on the screen. Finally, the endTouch() function is used to release the touch points and to end the pan event.

For more touch script examples, see scripts/examples/.

Member Function Documentation

void TouchScriptInterface::beginTouch(int id, int x, int y)

Begins the touch event by creating a touch point with the identifier id in the position specified by x and y.

void TouchScriptInterface::endTouch(int id, int x, int y)

Ends the touch event by releasing the touch point with the identifier id in the position specified by x and y.

void TouchScriptInterface::updateTouch(int id, int x, int y)

Moves the touch point with the identifier id to the position specified by x and y.

Available under certain Qt licenses.
Find out more.