1e41f4b71Sopenharmony_ci# Gesture Binding 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ciYou can bind to each component different gesture events and design the logic for responding to these events. When a gesture is successfully recognized, the ArkUI framework notifies the component of the gesture recognition result through event callback. 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ci## gesture (Common Gesture Binding Method) 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci```ts 11e41f4b71Sopenharmony_ci.gesture(gesture: GestureType, mask?: GestureMask) 12e41f4b71Sopenharmony_ci``` 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci**gesture** is a frequently used API for binding a gesture to a component. 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ciFor example, you can use it to bind the tap gesture to the **\<Text>** component. 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci```ts 20e41f4b71Sopenharmony_ci// xxx.ets 21e41f4b71Sopenharmony_ci@Entry 22e41f4b71Sopenharmony_ci@Component 23e41f4b71Sopenharmony_cistruct Index { 24e41f4b71Sopenharmony_ci build() { 25e41f4b71Sopenharmony_ci Column() { 26e41f4b71Sopenharmony_ci Text('Gesture').fontSize(28) 27e41f4b71Sopenharmony_ci // Use the gesture API to bind the tap gesture. 28e41f4b71Sopenharmony_ci .gesture( 29e41f4b71Sopenharmony_ci TapGesture() 30e41f4b71Sopenharmony_ci .onAction(() => { 31e41f4b71Sopenharmony_ci console.info('TapGesture is onAction'); 32e41f4b71Sopenharmony_ci })) 33e41f4b71Sopenharmony_ci } 34e41f4b71Sopenharmony_ci .height(200) 35e41f4b71Sopenharmony_ci .width(250) 36e41f4b71Sopenharmony_ci } 37e41f4b71Sopenharmony_ci} 38e41f4b71Sopenharmony_ci``` 39e41f4b71Sopenharmony_ci 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci## priorityGesture (Gesture Binding Method with Priority) 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci 44e41f4b71Sopenharmony_ci```ts 45e41f4b71Sopenharmony_ci.priorityGesture(gesture: GestureType, mask?: GestureMask) 46e41f4b71Sopenharmony_ci``` 47e41f4b71Sopenharmony_ci 48e41f4b71Sopenharmony_ciThe **priorityGesture** API binds gestures that are preferentially recognized to a component. 49e41f4b71Sopenharmony_ci 50e41f4b71Sopenharmony_ciBy default, the child component preferentially recognizes the gesture specified by **gesture**, and the parent component preferentially recognizes the gesture specified by **priorityGesture** (if set). 51e41f4b71Sopenharmony_ci 52e41f4b71Sopenharmony_ciIn the following example, the parent component **\<Column>** and child component **\<Text>** are both bound to the tap gesture. As the **\<Column>** is bound to the gesture through **priorityGesture**, the tap gesture recognized by the parent component is preferentially responded to. 53e41f4b71Sopenharmony_ci 54e41f4b71Sopenharmony_ci 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ci```ts 57e41f4b71Sopenharmony_ci// xxx.ets 58e41f4b71Sopenharmony_ci@Entry 59e41f4b71Sopenharmony_ci@Component 60e41f4b71Sopenharmony_cistruct Index { 61e41f4b71Sopenharmony_ci build() { 62e41f4b71Sopenharmony_ci Column() { 63e41f4b71Sopenharmony_ci Text('Gesture').fontSize(28) 64e41f4b71Sopenharmony_ci .gesture( 65e41f4b71Sopenharmony_ci TapGesture() 66e41f4b71Sopenharmony_ci .onAction(() => { 67e41f4b71Sopenharmony_ci console.info('Text TapGesture is onAction'); 68e41f4b71Sopenharmony_ci })) 69e41f4b71Sopenharmony_ci } 70e41f4b71Sopenharmony_ci .height(200) 71e41f4b71Sopenharmony_ci .width(250) 72e41f4b71Sopenharmony_ci // When the tap gesture is bound to the parent <Column> component through priorityGesture, the tap gesture event of the <Text> component is ignored when the text area is tapped, and the tap gesture event of the<Column> component is preferentially responded to. 73e41f4b71Sopenharmony_ci .priorityGesture( 74e41f4b71Sopenharmony_ci TapGesture() 75e41f4b71Sopenharmony_ci .onAction(() => { 76e41f4b71Sopenharmony_ci console.info('Column TapGesture is onAction'); 77e41f4b71Sopenharmony_ci }), GestureMask.IgnoreInternal) 78e41f4b71Sopenharmony_ci } 79e41f4b71Sopenharmony_ci} 80e41f4b71Sopenharmony_ci``` 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ci 83e41f4b71Sopenharmony_ci## parallelGesture (Parallel Gesture Binding Method) 84e41f4b71Sopenharmony_ci 85e41f4b71Sopenharmony_ci 86e41f4b71Sopenharmony_ci```ts 87e41f4b71Sopenharmony_ci.parallelGesture(gesture: GestureType, mask?: GestureMask) 88e41f4b71Sopenharmony_ci``` 89e41f4b71Sopenharmony_ci 90e41f4b71Sopenharmony_ciThe **parallelGesture** API binds to a component the gesture that can be triggered together with the child component gesture. 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ciBy default, the gesture event does not bubble up. When a parent component and a child component are bound to a same gesture, the gesture events bound to the parent component and the child component compete with each other, and a gesture event of at most one component can be responded to. When **parallelGesture** is set, the same gesture events can be triggered for the parent and child components, thereby implementing a bubbling effect. 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ci 95e41f4b71Sopenharmony_ci 96e41f4b71Sopenharmony_ci```ts 97e41f4b71Sopenharmony_ci// xxx.ets 98e41f4b71Sopenharmony_ci@Entry 99e41f4b71Sopenharmony_ci@Component 100e41f4b71Sopenharmony_cistruct Index { 101e41f4b71Sopenharmony_ci build() { 102e41f4b71Sopenharmony_ci Column() { 103e41f4b71Sopenharmony_ci Text('Gesture').fontSize(28) 104e41f4b71Sopenharmony_ci .gesture( 105e41f4b71Sopenharmony_ci TapGesture() 106e41f4b71Sopenharmony_ci .onAction(() => { 107e41f4b71Sopenharmony_ci console.info('Text TapGesture is onAction'); 108e41f4b71Sopenharmony_ci })) 109e41f4b71Sopenharmony_ci } 110e41f4b71Sopenharmony_ci .height(200) 111e41f4b71Sopenharmony_ci .width(250) 112e41f4b71Sopenharmony_ci // When parallelGesture is set, the tap gestures on the <Column> component and on the child <Text> component are both recognized. 113e41f4b71Sopenharmony_ci .parallelGesture( 114e41f4b71Sopenharmony_ci TapGesture() 115e41f4b71Sopenharmony_ci .onAction(() => { 116e41f4b71Sopenharmony_ci console.info('Column TapGesture is onAction'); 117e41f4b71Sopenharmony_ci }), GestureMask.Normal) 118e41f4b71Sopenharmony_ci } 119e41f4b71Sopenharmony_ci} 120e41f4b71Sopenharmony_ci``` 121e41f4b71Sopenharmony_ci 122e41f4b71Sopenharmony_ci 123e41f4b71Sopenharmony_ci>**NOTE** 124e41f4b71Sopenharmony_ci> 125e41f4b71Sopenharmony_ci>When the parent component and the child component are bound to both the click gesture and the double-click gesture, both the parent component and the child component respond only to the click gesture. 126