#鸿蒙通关秘籍#如何实现并行识别的组合手势?

HarmonyOS
2024-12-05 14:31:10
浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
墨海涛LAN

并行识别的组合手势允许多个手势同时进行识别,在HarmonyOS中设定GestureModeParallel来实现并行识别。下面展示如何绑定单击和双击手势,使它们并行识别。

// xxx.ets
@Entry
@Component
struct Index {
  @State count1: number = 0;
  @State count2: number = 0;

  build() {
    Column() {
      Text('Parallel gesture\n' + 'tapGesture count is 1:' + this.count1 + '\ntapGesture count is 2:' + this.count2 + '\n')
        .fontSize(28)
    }
    .height(200)
    .width('100%')
    .gesture(
      GestureGroup(GestureMode.Parallel,
        TapGesture({ count: 1 })
          .onAction(() => {
            this.count1++;
          }),
        TapGesture({ count: 2 })
          .onAction(() => {
            this.count2++;
          })
      )
    )
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
分享
微博
QQ
微信
回复
2024-12-05 16:36:15
相关问题
#鸿蒙学习大百科#什么是组合手势
1088浏览 • 1回复 待解决
语音识别的方法有哪些?
1414浏览 • 1回复 待解决
HarmonyOS 驾驶证书识别的demo
660浏览 • 1回复 待解决