add touch demo
This commit is contained in:
parent
56bf3bb4a1
commit
f9931ff883
@ -4,6 +4,13 @@ import { colors } from "./utils";
|
|||||||
@Entry
|
@Entry
|
||||||
class SimpleDemo extends Panel {
|
class SimpleDemo extends Panel {
|
||||||
build(rootView: Group) {
|
build(rootView: Group) {
|
||||||
|
let touchChild = stack([], {
|
||||||
|
layoutConfig: layoutConfig().just(),
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
backgroundColor: Color.WHITE,
|
||||||
|
})
|
||||||
|
|
||||||
let pinchChild = stack([], {
|
let pinchChild = stack([], {
|
||||||
layoutConfig: layoutConfig().just().configAlignment(Gravity.Center),
|
layoutConfig: layoutConfig().just().configAlignment(Gravity.Center),
|
||||||
width: 100,
|
width: 100,
|
||||||
@ -27,6 +34,43 @@ class SimpleDemo extends Panel {
|
|||||||
|
|
||||||
scroller(
|
scroller(
|
||||||
vlayout([
|
vlayout([
|
||||||
|
vlayout([
|
||||||
|
text({
|
||||||
|
text: "onTouch Demo",
|
||||||
|
layoutConfig: layoutConfig().mostWidth(),
|
||||||
|
textSize: 30,
|
||||||
|
textColor: Color.WHITE,
|
||||||
|
backgroundColor: colors[5],
|
||||||
|
textAlignment: gravity().center(),
|
||||||
|
height: 50,
|
||||||
|
}),
|
||||||
|
gestureContainer([
|
||||||
|
touchChild
|
||||||
|
], {
|
||||||
|
onTouchDown: (x: number, y: number) => {
|
||||||
|
modal(context).toast("onTouchDown x=" + x + " y=" + y)
|
||||||
|
},
|
||||||
|
onTouchMove: (x: number, y: number) => {
|
||||||
|
touchChild.x = x - 50
|
||||||
|
touchChild.y = y - 50
|
||||||
|
},
|
||||||
|
onTouchUp: (x: number, y: number) => {
|
||||||
|
modal(context).toast("onTouchUp x=" + x + " y=" + y)
|
||||||
|
},
|
||||||
|
onTouchCancel: (x: number, y: number) => {
|
||||||
|
modal(context).toast("onTouchCancel x=" + x + " y=" + y)
|
||||||
|
}
|
||||||
|
}).apply({
|
||||||
|
layoutConfig: layoutConfig().just().configAlignment(Gravity.Center),
|
||||||
|
width: 300,
|
||||||
|
height: 300,
|
||||||
|
backgroundColor: Color.BLACK
|
||||||
|
}),
|
||||||
|
]).apply({
|
||||||
|
layoutConfig: layoutConfig().mostWidth().fitHeight()
|
||||||
|
}),
|
||||||
|
|
||||||
|
|
||||||
vlayout([
|
vlayout([
|
||||||
text({
|
text({
|
||||||
text: "SingleTap, DoubleTap, LongPress Demo",
|
text: "SingleTap, DoubleTap, LongPress Demo",
|
||||||
|
Reference in New Issue
Block a user