1# Combined Gestures 2 3Continuous recognition, parallel recognition, and exclusive recognition are supported for a group of gestures. 4 5> **NOTE** 6> 7> The APIs of this module are supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. 8 9 10## APIs 11 12GestureGroup(mode: GestureMode, ...gesture: GestureType[]) 13 14- Parameters 15 | Name| Type| Mandatory| Default Value| Description| 16 | -------- | -------- | -------- | -------- | -------- | 17 | mode | [GestureMode](#gesturemode) | Yes| - | Recognition mode of combined gestures.| 18 | gesture | [TapGesture](ts-basic-gestures-tapgesture.md)<br>\| [LongPressGesture](ts-basic-gestures-longpressgesture.md)<br>\| [PanGesture](ts-basic-gestures-pangesture.md)<br>\| [PinchGesture](ts-basic-gestures-pinchgesture.md)<br>\| [RotationGesture](ts-basic-gestures-rotationgesture.md) | Yes| - | Variable-length parameter, indicating one or more basic gesture types. These gestures are recognized in combination.| 19 20## GestureMode 21 22| Name | Description | 23| --------- | ---------------------------------------- | 24| Sequence | Sequential recognition: Gestures are recognized in the registration sequence until all gestures are recognized successfully. When one gesture fails to be recognized, all gestures fail to be recognized.| 25| Parallel | Parallel recognition. Registered gestures are recognized concurrently until all gestures are recognized. The recognition result of each gesture does not affect each other. | 26| Exclusive | Exclusive recognition. Registered gestures are identified concurrently. If one gesture is successfully recognized, gesture recognition ends. | 27 28 29## Events 30 31| Name | Description | 32| ---------------------------------------- | ------------------------------------ | 33| onCancel(event: () => void) | Callback for the GestureMode.Sequence cancellation event.| 34 35 36## Example 37 38```ts 39// xxx.ets 40@Entry 41@Component 42struct GestureGroupExample { 43 @State count: number = 0 44 @State offsetX: number = 0 45 @State offsetY: number = 0 46 @State positionX: number = 0 47 @State positionY: number = 0 48 @State borderStyles: BorderStyle = BorderStyle.Solid 49 50 build() { 51 Column() { 52 Text('sequence gesture\n' + 'LongPress onAction:' + this.count + '\nPanGesture offset:\nX: ' + this.offsetX + '\n' + 'Y: ' + this.offsetY) 53 .fontSize(15) 54 } 55 .translate({ x: this.offsetX, y: this.offsetY, z: 0 }) 56 .height(150) 57 .width(200) 58 .padding(20) 59 .margin(20) 60 .border({ width: 3, style: this.borderStyles }) 61 .gesture( 62 // The following combined gestures are recognized in sequential recognition mode. If the long press gesture event is not triggered correctly, the drag gesture event will not be triggered. 63 GestureGroup(GestureMode.Sequence, 64 LongPressGesture({ repeat: true }) 65 .onAction((event: GestureEvent) => { 66 if (event.repeat) { 67 this.count++ 68 } 69 console.info('LongPress onAction') 70 }) 71 .onActionEnd(() => { 72 console.info('LongPress end') 73 }), 74 PanGesture() 75 .onActionStart(() => { 76 this.borderStyles = BorderStyle.Dashed 77 console.info('pan start') 78 }) 79 .onActionUpdate((event: GestureEvent) => { 80 this.offsetX = this.positionX + event.offsetX 81 this.offsetY = this.positionY + event.offsetY 82 console.info('pan update') 83 }) 84 .onActionEnd(() => { 85 this.positionX = this.offsetX 86 this.positionY = this.offsetY 87 this.borderStyles = BorderStyle.Solid 88 console.info('pan end') 89 }) 90 ) 91 .onCancel(() => { 92 console.info('sequence gesture canceled') 93 }) 94 ) 95 } 96} 97``` 98 99Diagram: 100 101In sequence recognition mode the long press gesture event is triggered first. 102 103 104 105After the long press gesture is recognized, the drag gesture event is triggered. 106 107  108