在多指touch事件上,当第二个手指触发的时候,回调的touch事件会短暂丢失第二根手指的move信息。
问题代码示例参考如下:
@Entry @Component struct TouchExample { @State text: string = '' @State eventType: string = '' build() { Column() { Button('Touch').height(50).width(200).margin(20) .onTouch((event?: TouchEvent) => { if (event) { let info = JSON.stringify(event.touches) console.info(`${event.touches.length}`, info) if (event.type === TouchType.Down) { this.eventType = 'Down' } if (event.type === TouchType.Up) { this.eventType = 'Up' } if (event.type === TouchType.Move) { this.eventType = 'Move' } this.text = 'TouchType:' + this.eventType + '\nDistance between touch point and touch element:\nx: ' + event.touches[0].x + '\n' + 'y: ' + event.touches[0].y + '\nComponent globalPos:(' + event.target.area.globalPosition.x + ',' + event.target.area.globalPosition.y + ')\nwidth:' + event.target.area.width + '\nheight:' + event.target.area.height + '\ntouches' + JSON.stringify(event.touches) } }) Text(this.text) }.width('100%').padding(30) } }