From f0054d23ae3737628f57067418473b53f6f2ef46 Mon Sep 17 00:00:00 2001 From: luoying_ace Date: Tue, 27 Sep 2022 07:52:30 +0000 Subject: [PATCH] update zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md. Signed-off-by: luoying_ace --- .../ts-basic-gestures-longpressgesture.md | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md index 8174f00545..b66e498881 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-longpressgesture.md @@ -1,6 +1,6 @@ # LongPressGesture -用于触发长按手势事件,触发长按手势的最少手指数为1,最短时间为500毫秒。 +用于触发长按手势事件,触发长按手势的最少手指数为1,最短长按时间为500毫秒。 > **说明:** > @@ -36,24 +36,31 @@ LongPressGesture(value?: { fingers?: number, repeat?: boolean, duration?: number @Entry @Component struct LongPressGestureExample { - @State count: number = 0 + @State count: number = 0; build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Text('LongPress onAction:' + this.count) + Column() { + Text('LongPress onAction:' + this.count).fontSize(28) + //单指长按文本触发该手势事件 + .gesture( + LongPressGesture({ repeat: true }) + //由于repeat设置为true,长按动作存在时会连续触发,触发间隔为duration(默认值500ms) + .onAction((event: GestureEvent) => { + if (event.repeat) { + this.count++; + } + }) + //长按动作一结束触发 + .onActionEnd(() => { + this.count = 0; + }) + ) } - .height(200).width(300).padding(60).border({ width:1 }).margin(30) - .gesture( - LongPressGesture({ repeat: true }) - // 长按动作存在会连续触发 - .onAction((event: GestureEvent) => { - if (event.repeat) { this.count++ } - }) - // 长按动作一结束触发 - .onActionEnd(() => { - this.count = 0 - }) - ) + .height(200) + .width(300) + .padding(20) + .border({ width: 3 }) + .margin(30) } } ``` -- GitLab