Skip to content

Latest commit

 

History

History
251 lines (165 loc) · 3.08 KB

touch.md

File metadata and controls

251 lines (165 loc) · 3.08 KB

Touch

Overview

The touch control can be used for receiving multi-touch events.

<touch text="touch here!" ontouchabs="moved" />
actions.moved = function (id, x, y)
    print("touch point " .. id .. " at " .. x .. " " .. y);
end

Properties

id

Set the ID for this control so that it can be updated later. See layout library.

<touch id="my_touch" />

visibility

Set the visibility state using visible or invisible or gone.

<touch visibility="gone" />

text

Set the text to be shown in the background.

<touch text="hello world" />

image

Set the background image.

<touch image="bg.png" />

Styling

See the styling page for more details.

Events

ontap

Occurs when the touch area is tapped.

<touch ontap="tapped" />
actions.tapped = function ()
    ...
end

onhold

Occurs when the touch area is held down.

<touch onhold="held" />
actions.held = function ()
    ...
end

ondoubletap

Occurs when the touch area is double tapped.

<touch ondoubletap="double" />
actions.double = function ()
    ...
end

ondown

Occurs when touch begins.

<touch ondown="down" />
actions.down = function ()
    ...
end

onup

Occurs when touch ends.

<touch onup="up" />
actions.up = function ()
    ...
end

ontouchsize

Occurs when the touch area changes size.

<touch ontouchsize="touch_size" />
actions.touch_size = function (w, h, oldw, oldh)
    ...
end

ontouchstart

Occurs when a multi-touch event starts (id is the pointer id).

<touch ontouchstart="touch_start" />
actions.touch_start = function (id, x, y)
    ...
end

ontouchdelta

Occurs on multi-touch movement (id is the pointer id).

<touch ontouchdelta="touch_delta" />
actions.touch_delta = function (id, deltax, deltay)
    ...
end

ontouchabs

Occurs on multi-touch movement (id is the pointer id).

<touch ontouchabs="touch_abs" />
actions.touch_abs = function (id, absx, absy)
    ...
end

ontouchend

Occurs when a multi-touch event ends (id is the pointer id).

<touch ontouchend="touch_end" />
actions.touch_end = function (id, x, y)
    ...
end

onmultitap

Occurs on a multi-touch tap occurs with n fingers.

<touch onmultitap="multitap" />
actions.multitap = function (n)
    ...
end