未验证 提交 398d5062 编写于 作者: L luoying_ace 提交者: Gitee

update zh-cn/application-dev/reference/arkui-ts/ts-combined-gestures.md.

Signed-off-by: Nluoying_ace <luoying19@huawei.com>
上级 fc8a0a92
# 组合手势 # 组合手势
手势识别组多种手势组合为复合手势,支持连续识别、并行识别和互斥识别。 手势识别组合,即多种手势组合为复合手势,支持连续识别、并行识别和互斥识别。
> **说明:** > **说明:**
>
> 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 > 从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
...@@ -38,39 +39,55 @@ GestureGroup(mode: GestureMode, ...gesture: GestureType[]) ...@@ -38,39 +39,55 @@ GestureGroup(mode: GestureMode, ...gesture: GestureType[])
@Entry @Entry
@Component @Component
struct GestureGroupExample { struct GestureGroupExample {
@State count: number = 0 @State count: number = 0;
@State offsetX: number = 0 @State offsetX: number = 0;
@State offsetY: number = 0 @State offsetY: number = 0;
@State borderStyles: BorderStyle = BorderStyle.Solid @State positionX: number = 0;
@State positionY: number = 0;
@State borderStyles: BorderStyle = BorderStyle.Solid;
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { Column() {
Text('sequence gesture\n' + 'LongPress onAction:' + this.count + '\nPanGesture offset:\nX: ' + this.offsetX + '\n' + 'Y: ' + this.offsetY) Text('sequence gesture\n' + 'LongPress onAction:' + this.count + '\nPanGesture offset:\nX: ' + this.offsetX + '\n' + 'Y: ' + this.offsetY)
}.translate({ x: this.offsetX, y: this.offsetY, z: 5 }) }
.height(100).width(200).padding(10).margin(80).border({ width: 1, style: this.borderStyles }) .translate({ x: this.offsetX, y: this.offsetY, z: 0 })
.height(150)
.width(200)
.padding(20)
.margin(20)
.border({ width: 3, style: this.borderStyles })
.gesture( .gesture(
GestureGroup(GestureMode.Sequence, //以下组合手势为顺序识别,当长按手势事件未正常触发时则不会触发拖动手势事件
LongPressGesture({ repeat: true }) GestureGroup(GestureMode.Sequence,
.onAction((event: GestureEvent) => { LongPressGesture({ repeat: true })
if (event.repeat) {this.count++} .onAction((event: GestureEvent) => {
console.log('LongPress onAction') if (event.repeat) {
}) this.count++;
.onActionEnd(() => { }
console.log('LongPress end') console.info('LongPress onAction');
}), })
PanGesture({}) .onActionEnd(() => {
.onActionStart(() => { console.info('LongPress end');
this.borderStyles = BorderStyle.Dashed }),
console.log('pan start') PanGesture()
}) .onActionStart(() => {
.onActionUpdate((event: GestureEvent) => { this.borderStyles = BorderStyle.Dashed;
this.offsetX = event.offsetX console.info('pan start');
this.offsetY = event.offsetY })
console.log('pan update') .onActionUpdate((event: GestureEvent) => {
}) this.offsetX = this.positionX + event.offsetX;
) this.offsetY = this.positionY + event.offsetY;
console.info('pan update');
})
.onActionEnd(() => {
this.positionX = this.offsetX;
this.positionY = this.offsetY;
this.borderStyles = BorderStyle.Solid;
console.info('pan end');
})
)
.onCancel(() => { .onCancel(() => {
console.log('sequence gesture canceled') console.info('sequence gesture canceled');
}) })
) )
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册