TapGesture
A tap gesture is a "pointer down & up" within a small radius. It's typically used to build buttons or checkboxes.
modifier TapGesture
Example
import { TapGesture, TapGestureEvent, Rectangle, Frame } from ui
import { random } from math
fun random_color() -> (Color) {
return Color(0xFF000000 | random(from: 0, to: 16777216))
}
component TappableBox {
color: Color = random_color()
Rectangle(color: self.color) with {
Frame(width: 50, height: 50)
TapGesture(fun (event: TapGestureEvent) {
self.color = random_color()
})
}
}
export var main: Component = TappableBox()
Constructors
Single Tap
constructor(_ single: (TapGestureEvent) -> ())
_ single: (TapGestureEvent) -> ()Called when a single tap (pointer down and up) occured.
See TapGestureEvent.
Detailed Callbacks
constructor(down: (TapGestureEvent) -> (), up: (TapGestureEvent) -> (), single: (TapGestureEvent) -> (), double: (TapGestureEvent) -> (), cancel: () -> ())
down: (TapGestureEvent) -> ()Called when the pointer down occurs.
up: (TapGestureEvent) -> ()Called when the pointer up occurs.
single: (TapGestureEvent) -> ()Called when a single tap (pointer down and up) occured.
When no
doublehandler is provided every pointer up will trigger thesinglehandler.In case both
singleanddoubleare provided, the single callback might occur on a timeout to allow distinguishing between a single or double tap.down <timeout> up -> single tapdown up <timeout> -> single tapdown up down up -> double tap (single not called)down up down <timeout> up -> double tap (single not called)infoThe timeout is the double click speed system setting of the user.
double: (TapGestureEvent) -> ()Called when every second pointer down & up sequence completes within the allowed time and distance limit for a double tap.
cancel: () -> ()Called when the tap was cancelled due to another gesture taking over.
Layout Behavior
None