1e41f4b71Sopenharmony_ci# Binding Gesture Events
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ciThe ArkUI development framework provides tap, drag, swipe, long press, pinch, and rotation gestures through its NDK APIs. By binding different gestures to specified components and setting corresponding callbacks, you can achieve the desired gesture interaction capabilities.
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ciThe following is a simple example to illustrate how to implement gesture binding.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci1. Create a **Column** node to which gestures will be bound.
11e41f4b71Sopenharmony_ci   ```
12e41f4b71Sopenharmony_ci   // Create a Column node.
13e41f4b71Sopenharmony_ci   auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN);
14e41f4b71Sopenharmony_ci   // Set the background color.
15e41f4b71Sopenharmony_ci   ArkUI_NumberValue value[] = {{.u32 = 0xff112233}};
16e41f4b71Sopenharmony_ci   ArkUI_AttributeItem item = {value, 1};
17e41f4b71Sopenharmony_ci   nodeAPI->setAttribute(column, NODE_BACKGROUND_COLOR, &item);
18e41f4b71Sopenharmony_ci   // Set the width.
19e41f4b71Sopenharmony_ci   ArkUI_NumberValue widthValue[] = {{400}};
20e41f4b71Sopenharmony_ci   ArkUI_AttributeItem width = {widthValue, 1};
21e41f4b71Sopenharmony_ci   nodeAPI->setAttribute(column, NODE_WIDTH, &width);
22e41f4b71Sopenharmony_ci   //Set the height.
23e41f4b71Sopenharmony_ci   ArkUI_NumberValue heightValue[] = {{400}};
24e41f4b71Sopenharmony_ci   ArkUI_AttributeItem height = {heightValue, 1};
25e41f4b71Sopenharmony_ci   nodeAPI->setAttribute(column, NODE_HEIGHT, &height);
26e41f4b71Sopenharmony_ci   ```
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci2. Create a single-finger long-press gesture with a 1-second activation threshold.
29e41f4b71Sopenharmony_ci   ```
30e41f4b71Sopenharmony_ci   // Obtain the set of native gesture APIs.
31e41f4b71Sopenharmony_ci   auto gestureApi = reinterpret_cast<ArkUI_NativeGestureAPI_1 *>(
32e41f4b71Sopenharmony_ci               OH_ArkUI_QueryModuleInterfaceByName(ARKUI_NATIVE_GESTURE, "ArkUI_NativeGestureAPI_1"));
33e41f4b71Sopenharmony_ci   // Create a long press gesture.
34e41f4b71Sopenharmony_ci   auto longPressGesture = gestureApi->createLongPressGesture(1, true, 1000);
35e41f4b71Sopenharmony_ci   ```
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci3. Bind the created gesture to the **Column** node created in step 1.
38e41f4b71Sopenharmony_ci   ```
39e41f4b71Sopenharmony_ci   // Set the callback.
40e41f4b71Sopenharmony_ci   auto onActionCallBack = [](ArkUI_GestureEvent *event, void *extraParam) {
41e41f4b71Sopenharmony_ci       // Callback content
42e41f4b71Sopenharmony_ci   };
43e41f4b71Sopenharmony_ci   
44e41f4b71Sopenharmony_ci   // Set the gesture to the component.
45e41f4b71Sopenharmony_ci   gestureApi->setGestureEventTarget(longPressGesture, GESTURE_EVENT_ACTION_ACCEPT | GESTURE_EVENT_ACTION_UPDATE | GESTURE_EVENT_ACTION_END, column, onActionCallBack);
46e41f4b71Sopenharmony_ci   
47e41f4b71Sopenharmony_ci   gestureApi->addGestureToNode(column, longPressGesture, PARALLEL, NORMAL_GESTURE_MASK);
48e41f4b71Sopenharmony_ci   ```
49e41f4b71Sopenharmony_ci
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci## Single Gestures
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ciThe following outlines how to create single gestures and the event callbacks they support:
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ci- Tap gesture
56e41f4b71Sopenharmony_ci  Triggers a callback on tap, set by the number of taps and fingers required.
57e41f4b71Sopenharmony_ci
58e41f4b71Sopenharmony_ci  ```
59e41f4b71Sopenharmony_ci  ArkUI_GestureRecognizer* (*createTapGesture)(int32_t countNum, int32_t fingersNum);
60e41f4b71Sopenharmony_ci  ```
61e41f4b71Sopenharmony_ci
62e41f4b71Sopenharmony_ci- Pan gesture
63e41f4b71Sopenharmony_ci  Triggers a callback during dragging, set by the number of fingers, direction, and distance in px.
64e41f4b71Sopenharmony_ci  ```
65e41f4b71Sopenharmony_ci  ArkUI_GestureRecognizer* (*createPanGesture)(
66e41f4b71Sopenharmony_ci  int32_t fingersNum, ArkUI_GestureDirectionMask directions, double distanceNum);
67e41f4b71Sopenharmony_ci  ```
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci- Long press gesture
70e41f4b71Sopenharmony_ci  Triggers a callback on long press, set by the number of fingers, hold-down time in milliseconds, and repeatability.
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci  ```
73e41f4b71Sopenharmony_ci  ArkUI_GestureRecognizer* (*createLongPressGesture)(int32_t fingersNum, bool repeatResult, int32_t durationNum);
74e41f4b71Sopenharmony_ci  ```
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ci- Pinch gesture
77e41f4b71Sopenharmony_ci  Triggers a callback on pinching, set by the number of fingers (at least 2) and the pinch distance (in px).
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci  ```
80e41f4b71Sopenharmony_ci  ArkUI_GestureRecognizer* (*createPinchGesture)(int32_t fingersNum, double distanceNum);
81e41f4b71Sopenharmony_ci  ```
82e41f4b71Sopenharmony_ci
83e41f4b71Sopenharmony_ci- Rotation gesture
84e41f4b71Sopenharmony_ci  Triggers a callback on rotation, set by the number of fingers (at least 2) and angle.
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci  ```
87e41f4b71Sopenharmony_ci  ArkUI_GestureRecognizer* (*createRotationGesture)(int32_t fingersNum, double angleNum);
88e41f4b71Sopenharmony_ci  ```
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci- Swipe gesture
91e41f4b71Sopenharmony_ci  Triggers a callback on swiping, set by the number of fingers (at least 1), direction, and speed in px/s.
92e41f4b71Sopenharmony_ci
93e41f4b71Sopenharmony_ci  ```
94e41f4b71Sopenharmony_ci  ArkUI_GestureRecognizer* (*createSwipeGesture)(
95e41f4b71Sopenharmony_ci  int32_t fingersNum, ArkUI_GestureDirectionMask directions, double speedNum);
96e41f4b71Sopenharmony_ci  ```
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci## Combined Gestures
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ciCombined gestures are created by combining multiple single gestures, and their types are declared with **ArkUI_GroupGestureMode** in **GroupGesture**.
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ci**ArkUI_GroupGestureMode** supports the following options: **SEQUENTIAL_GROUP** (sequential recognition), **PARALLEL_GROUP** (parallel recognition), **EXCLUSIVE_GROUP** (exclusive recognition).
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_ci### Sequential Recognition
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ciFor combined gestures with sequential recognition, the value of **ArkUI_GroupGestureMode** is **SEQUENTIAL_GROUP**. In this gesture recognition mode, gestures are recognized in the order they were registered until they are all recognized successfully. If any of the registered gestures fails to be recognized, subsequent gestures will also fail. Only the last gesture in a sequential group can respond to the **GESTURE_EVENT_ACTION_END** event.
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ciThe following demonstrates how to create a combined gesture that recognizes a long press followed by a swipe in sequence:
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ci```
113e41f4b71Sopenharmony_ciArkUI_NodeHandle testGestureExample() {
114e41f4b71Sopenharmony_ci    auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN);
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ci    // Create a Column node.
117e41f4b71Sopenharmony_ci    ArkUI_NumberValue value[] = {{.u32 = 0xff112233}};
118e41f4b71Sopenharmony_ci    ArkUI_AttributeItem item = {value, 1};
119e41f4b71Sopenharmony_ci    nodeAPI->setAttribute(column, NODE_BACKGROUND_COLOR, &item);
120e41f4b71Sopenharmony_ci    ArkUI_NumberValue widthValue[] = {{200}};
121e41f4b71Sopenharmony_ci    ArkUI_AttributeItem width = {widthValue, 1};
122e41f4b71Sopenharmony_ci    nodeAPI->setAttribute(column, NODE_WIDTH, &width);
123e41f4b71Sopenharmony_ci    ArkUI_NumberValue heightValue[] = {{200}};
124e41f4b71Sopenharmony_ci    ArkUI_AttributeItem height = {heightValue, 1};
125e41f4b71Sopenharmony_ci    nodeAPI->setAttribute(column, NODE_HEIGHT, &height);
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci    // Check for the gesture API.
128e41f4b71Sopenharmony_ci    auto gestureApi = reinterpret_cast<ArkUI_NativeGestureAPI_1 *>(
129e41f4b71Sopenharmony_ci        OH_ArkUI_QueryModuleInterfaceByName(ARKUI_NATIVE_GESTURE, "ArkUI_NativeGestureAPI_1"));
130e41f4b71Sopenharmony_ci    if (gestureApi->createGroupGesture) {
131e41f4b71Sopenharmony_ci        OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager",
132e41f4b71Sopenharmony_ci                     "onPanActionCallBack, createGroupGesture api exist");
133e41f4b71Sopenharmony_ci    } else {
134e41f4b71Sopenharmony_ci        OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager",
135e41f4b71Sopenharmony_ci                     "onPanActionCallBack, createGroupGesture api not exist");
136e41f4b71Sopenharmony_ci    }
137e41f4b71Sopenharmony_ci    auto groupGesture = gestureApi->createGroupGesture(ArkUI_GroupGestureMode::SEQUENTIAL_GROUP);
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_ci    // Create a long press gesture.
140e41f4b71Sopenharmony_ci    auto longPressGesture = gestureApi->createLongPressGesture(1, true, 500);
141e41f4b71Sopenharmony_ci    if (gestureApi->getGestureType) {
142e41f4b71Sopenharmony_ci        ArkUI_GestureRecognizerType type = gestureApi->getGestureType(longPressGesture);
143e41f4b71Sopenharmony_ci        OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager",
144e41f4b71Sopenharmony_ci                     "onPanActionCallBack longPressGesture,ArkUI_GestureRecognizerType%{public}d", type);
145e41f4b71Sopenharmony_ci    }
146e41f4b71Sopenharmony_ci    // Set a callback for the long press gesture.
147e41f4b71Sopenharmony_ci    auto onActionCallBackPanLongPress = [](ArkUI_GestureEvent *event, void *extraParam) {
148e41f4b71Sopenharmony_ci        ArkUI_GestureEventActionType actionType = OH_ArkUI_GestureEvent_GetActionType(event);
149e41f4b71Sopenharmony_ci
150e41f4b71Sopenharmony_ci        float velocity = OH_ArkUI_PanGesture_GetVelocity(event);
151e41f4b71Sopenharmony_ci        float velocityX = OH_ArkUI_PanGesture_GetVelocityX(event);
152e41f4b71Sopenharmony_ci        float velocityY = OH_ArkUI_PanGesture_GetVelocityY(event);
153e41f4b71Sopenharmony_ci       float OffsetX = OH_ArkUI_PanGesture_GetOffsetX(event);
154e41f4b71Sopenharmony_ci        float OffsetY = OH_ArkUI_PanGesture_GetOffsetY(event);
155e41f4b71Sopenharmony_ci        float scale = OH_ArkUI_PinchGesture_GetScale(event);
156e41f4b71Sopenharmony_ci        float CenterX = OH_ArkUI_PinchGesture_GetCenterX(event);
157e41f4b71Sopenharmony_ci        float CenterY = OH_ArkUI_PinchGesture_GetCenterY(event);
158e41f4b71Sopenharmony_ci        float angle = OH_ArkUI_SwipeGesture_GetAngle(event);
159e41f4b71Sopenharmony_ci        float VelocityS = OH_ArkUI_SwipeGesture_GetVelocity(event);
160e41f4b71Sopenharmony_ci        float angleR = OH_ArkUI_RotationGesture_GetAngle(event);
161e41f4b71Sopenharmony_ci       float repeat = OH_ArkUI_LongPress_GetRepeatCount(event);
162e41f4b71Sopenharmony_ci
163e41f4b71Sopenharmony_ci        OH_LOG_Print(
164e41f4b71Sopenharmony_ci            LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager",
165e41f4b71Sopenharmony_ci            "onPanActionCallBack,longPressGesturecallback actionType:%{public}d,velocity%{public}f,velocityX"
166e41f4b71Sopenharmony_ci            "%{public}f;"
167e41f4b71Sopenharmony_ci            "velocityY%{public}f,OffsetX%{public}f,OffsetY%{public}f,scale%{public}fCenterX"
168e41f4b71Sopenharmony_ci            "%{public}fCenterY"
169e41f4b71Sopenharmony_ci            "%{public}fangle%{public}fVelocityS%{public}fangleR%{public}frepeat%{public}f",
170e41f4b71Sopenharmony_ci            actionType, velocity, velocityX, velocityY, OffsetX, OffsetY, scale, CenterX, CenterY, angle, VelocityS,
171e41f4b71Sopenharmony_ci            angleR, repeat);
172e41f4b71Sopenharmony_ci    };
173e41f4b71Sopenharmony_ci    gestureApi->setGestureEventTarget(longPressGesture,
174e41f4b71Sopenharmony_ci                                      GESTURE_EVENT_ACTION_ACCEPT | GESTURE_EVENT_ACTION_UPDATE | GESTURE_EVENT_ACTION_CANCEL,
175e41f4b71Sopenharmony_ci                                      column, onActionCallBackPanLongPress);
176e41f4b71Sopenharmony_ci
177e41f4b71Sopenharmony_ci    // Add the long press gesture to the gesture group.
178e41f4b71Sopenharmony_ci    if (gestureApi->addChildGesture) {
179e41f4b71Sopenharmony_ci        gestureApi->addChildGesture(groupGesture, longPressGesture);
180e41f4b71Sopenharmony_ci        OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "onPanActionCallBack, addChildGesture longPressGesture");
181e41f4b71Sopenharmony_ci    }
182e41f4b71Sopenharmony_ci    // Create a swipe gesture.
183e41f4b71Sopenharmony_ci    auto swipeGesture = gestureApi->createSwipeGesture(1, GESTURE_DIRECTION_ALL, 100);
184e41f4b71Sopenharmony_ci    if (gestureApi->getGestureType) {
185e41f4b71Sopenharmony_ci        ArkUI_GestureRecognizerType type = gestureApi->getGestureType(swipeGesture);
186e41f4b71Sopenharmony_ci        OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager",
187e41f4b71Sopenharmony_ci                     "onPanActionCallBack, ArkUI_GestureRecognizerType %{public}d", type);
188e41f4b71Sopenharmony_ci    }
189e41f4b71Sopenharmony_ci    // Set a callback for the swipe gesture.
190e41f4b71Sopenharmony_ci    auto onActionCallBack = [](ArkUI_GestureEvent *event, void *extraParam) {
191e41f4b71Sopenharmony_ci        ArkUI_GestureEventActionType actionType = OH_ArkUI_GestureEvent_GetActionType(event);
192e41f4b71Sopenharmony_ci
193e41f4b71Sopenharmony_ci        float velocity = OH_ArkUI_PanGesture_GetVelocity(event);
194e41f4b71Sopenharmony_ci        float velocityX = OH_ArkUI_PanGesture_GetVelocityX(event);
195e41f4b71Sopenharmony_ci        float velocityY = OH_ArkUI_PanGesture_GetVelocityY(event);
196e41f4b71Sopenharmony_ci        float OffsetX = OH_ArkUI_PanGesture_GetOffsetX(event);
197e41f4b71Sopenharmony_ci        float OffsetY = OH_ArkUI_PanGesture_GetOffsetY(event);
198e41f4b71Sopenharmony_ci        float scale = OH_ArkUI_PinchGesture_GetScale(event);
199e41f4b71Sopenharmony_ci        float CenterX = OH_ArkUI_PinchGesture_GetCenterX(event);
200e41f4b71Sopenharmony_ci        float CenterY = OH_ArkUI_PinchGesture_GetCenterY(event);
201e41f4b71Sopenharmony_ci        float angle = OH_ArkUI_SwipeGesture_GetAngle(event);
202e41f4b71Sopenharmony_ci        float VelocityS = OH_ArkUI_SwipeGesture_GetVelocity(event);
203e41f4b71Sopenharmony_ci        float angleR = OH_ArkUI_RotationGesture_GetAngle(event);
204e41f4b71Sopenharmony_ci        float repeat = OH_ArkUI_LongPress_GetRepeatCount(event);
205e41f4b71Sopenharmony_ci
206e41f4b71Sopenharmony_ci
207e41f4b71Sopenharmony_ci        // Print logs.
208e41f4b71Sopenharmony_ci        OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager",
209e41f4b71Sopenharmony_ci                     "onPanActionCallBack, swipeGesture callback actionType: %{public}d, velocity "
210e41f4b71Sopenharmony_ci                     "%{public}f,velocityX "
211e41f4b71Sopenharmony_ci                     "%{public}f; "
212e41f4b71Sopenharmony_ci                     "velocityY %{public}f, OffsetX %{public}f, OffsetY %{public}f, scale %{public}fCenterX "
213e41f4b71Sopenharmony_ci                     "%{public}f CenterY"
214e41f4b71Sopenharmony_ci                     " %{public}f angle %{public}f VelocityS %{public}f angleR %{public}f repeat %{public}f",
215e41f4b71Sopenharmony_ci                     actionType, velocity, velocityX, velocityY, OffsetX, OffsetY, scale, CenterX, CenterY, angle,
216e41f4b71Sopenharmony_ci                     VelocityS, angleR, repeat);
217e41f4b71Sopenharmony_ci
218e41f4b71Sopenharmony_ci        ArkUI_NumberValue value[] = {{.f32 = 0}, {.f32 = 0}, {.f32 = 0}, {.f32 = angleR}, {.f32 = 0}};
219e41f4b71Sopenharmony_ci        ArkUI_AttributeItem item = {value, 5};
220e41f4b71Sopenharmony_ci        auto column = reinterpret_cast<ArkUI_NodeHandle>(extraParam);
221e41f4b71Sopenharmony_ci        nodeAPI->setAttribute(column, NODE_ROTATE, &item);
222e41f4b71Sopenharmony_ci    };
223e41f4b71Sopenharmony_ci
224e41f4b71Sopenharmony_ci    gestureApi->setGestureEventTarget(
225e41f4b71Sopenharmony_ci        swipeGesture, GESTURE_EVENT_ACTION_ACCEPT | GESTURE_EVENT_ACTION_UPDATE | GESTURE_EVENT_ACTION_END, column,
226e41f4b71Sopenharmony_ci        onActionCallBack);
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ci    // Add the swipe press gesture to the gesture group.
229e41f4b71Sopenharmony_ci    if (gestureApi->addChildGesture) {
230e41f4b71Sopenharmony_ci        gestureApi->addChildGesture(groupGesture, swipeGesture);
231e41f4b71Sopenharmony_ci        OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager",
232e41f4b71Sopenharmony_ci                     "onPanActionCallBack, addChildGesture swipeGesture");
233e41f4b71Sopenharmony_ci    }
234e41f4b71Sopenharmony_ci    // Set the gesture group to the component.
235e41f4b71Sopenharmony_ci    gestureApi->addGestureToNode(column, groupGesture, PRIORITY, NORMAL_GESTURE_MASK);
236e41f4b71Sopenharmony_ci    return column;
237e41f4b71Sopenharmony_ci}
238e41f4b71Sopenharmony_ci```
239e41f4b71Sopenharmony_ci
240e41f4b71Sopenharmony_ci
241e41f4b71Sopenharmony_ci### Parallel Recognition
242e41f4b71Sopenharmony_ci
243e41f4b71Sopenharmony_ciFor combined gestures with parallel recognition, the value of **ArkUI_GroupGestureMode** is **PARALLEL_GROUP**. In this gesture recognition mode, gestures registered in the combined gestures will be recognized at the same time until they are all recognized successfully. The gestures are recognized in parallel without affecting each other.
244e41f4b71Sopenharmony_ci
245e41f4b71Sopenharmony_ciThe following demonstrates how to create a combined gesture that recognizes long press and swipe gestures in parallel:
246e41f4b71Sopenharmony_ci
247e41f4b71Sopenharmony_ci```
248e41f4b71Sopenharmony_ciArkUI_NodeHandle testGestureExample() {
249e41f4b71Sopenharmony_ci    auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN);
250e41f4b71Sopenharmony_ci
251e41f4b71Sopenharmony_ci    // Create a Column node.
252e41f4b71Sopenharmony_ci    ArkUI_NumberValue value[] = {{.u32 = 0xff112233}};
253e41f4b71Sopenharmony_ci    ArkUI_AttributeItem item = {value, 1};
254e41f4b71Sopenharmony_ci    nodeAPI->setAttribute(column, NODE_BACKGROUND_COLOR, &item);
255e41f4b71Sopenharmony_ci    ArkUI_NumberValue widthValue[] = {{200}};
256e41f4b71Sopenharmony_ci    ArkUI_AttributeItem width = {widthValue, 1};
257e41f4b71Sopenharmony_ci    nodeAPI->setAttribute(column, NODE_WIDTH, &width);
258e41f4b71Sopenharmony_ci    ArkUI_NumberValue heightValue[] = {{200}};
259e41f4b71Sopenharmony_ci    ArkUI_AttributeItem height = {heightValue, 1};
260e41f4b71Sopenharmony_ci    nodeAPI->setAttribute(column, NODE_HEIGHT, &height);
261e41f4b71Sopenharmony_ci
262e41f4b71Sopenharmony_ci    // Check for the gesture API.
263e41f4b71Sopenharmony_ci    auto gestureApi = reinterpret_cast<ArkUI_NativeGestureAPI_1 *>(
264e41f4b71Sopenharmony_ci        OH_ArkUI_QueryModuleInterfaceByName(ARKUI_NATIVE_GESTURE, "ArkUI_NativeGestureAPI_1"));
265e41f4b71Sopenharmony_ci    if (gestureApi->createGroupGesture) {
266e41f4b71Sopenharmony_ci        OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager",
267e41f4b71Sopenharmony_ci                     "onPanActionCallBack, createGroupGesture api exist");
268e41f4b71Sopenharmony_ci    } else {
269e41f4b71Sopenharmony_ci        OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager",
270e41f4b71Sopenharmony_ci                     "onPanActionCallBack, createGroupGesture api not exist");
271e41f4b71Sopenharmony_ci    }
272e41f4b71Sopenharmony_ci
273e41f4b71Sopenharmony_ci    // Create a gesture group.
274e41f4b71Sopenharmony_ci    auto groupGesture = gestureApi->createGroupGesture(ArkUI_GroupGestureMode::PARALLEL_GROUP);
275e41f4b71Sopenharmony_ci
276e41f4b71Sopenharmony_ci    // Create a long press gesture.
277e41f4b71Sopenharmony_ci    auto longPressGesture = gestureApi->createLongPressGesture(1, true, 500);
278e41f4b71Sopenharmony_ci    if (gestureApi->getGestureType) {
279e41f4b71Sopenharmony_ci        ArkUI_GestureRecognizerType type = gestureApi->getGestureType(longPressGesture);
280e41f4b71Sopenharmony_ci        OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager",
281e41f4b71Sopenharmony_ci                     "onPanActionCallBack,ArkUI_GestureRecognizerType%{public}d", type);
282e41f4b71Sopenharmony_ci    }
283e41f4b71Sopenharmony_ci    // Set a callback for the long press gesture.
284e41f4b71Sopenharmony_ci    auto onActionCallBackPanLongPress = [](ArkUI_GestureEvent *event, void *extraParam) {
285e41f4b71Sopenharmony_ci        ArkUI_GestureEventActionType actionType = OH_ArkUI_GestureEvent_GetActionType(event);
286e41f4b71Sopenharmony_ci
287e41f4b71Sopenharmony_ci        float velocity = OH_ArkUI_PanGesture_GetVelocity(event);
288e41f4b71Sopenharmony_ci        float velocityX = OH_ArkUI_PanGesture_GetVelocityX(event);
289e41f4b71Sopenharmony_ci        float velocityY = OH_ArkUI_PanGesture_GetVelocityY(event);
290e41f4b71Sopenharmony_ci        float OffsetX = OH_ArkUI_PanGesture_GetOffsetX(event);
291e41f4b71Sopenharmony_ci        float OffsetY = OH_ArkUI_PanGesture_GetOffsetY(event);
292e41f4b71Sopenharmony_ci        float scale = OH_ArkUI_PinchGesture_GetScale(event);
293e41f4b71Sopenharmony_ci        float CenterX = OH_ArkUI_PinchGesture_GetCenterX(event);
294e41f4b71Sopenharmony_ci        float CenterY = OH_ArkUI_PinchGesture_GetCenterY(event);
295e41f4b71Sopenharmony_ci        float angle = OH_ArkUI_SwipeGesture_GetAngle(event);
296e41f4b71Sopenharmony_ci        float VelocityS = OH_ArkUI_SwipeGesture_GetVelocity(event);
297e41f4b71Sopenharmony_ci        float angleR = OH_ArkUI_RotationGesture_GetAngle(event);
298e41f4b71Sopenharmony_ci        float repeat = OH_ArkUI_LongPress_GetRepeatCount(event);
299e41f4b71Sopenharmony_ci
300e41f4b71Sopenharmony_ci        OH_LOG_Print(
301e41f4b71Sopenharmony_ci            LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager",
302e41f4b71Sopenharmony_ci            "onPanActionCallBack,longPressGesturecallback actionType:%{public}d,velocity%{public}f,velocityX"
303e41f4b71Sopenharmony_ci            "%{public}f;"
304e41f4b71Sopenharmony_ci            "velocityY%{public}f,OffsetX%{public}f,OffsetY%{public}f,scale%{public}fCenterX"
305e41f4b71Sopenharmony_ci            "%{public}fCenterY"
306e41f4b71Sopenharmony_ci            "%{public}fangle%{public}fVelocityS%{public}fangleR%{public}frepeat%{public}f",
307e41f4b71Sopenharmony_ci            actionType, velocity, velocityX, velocityY, OffsetX, OffsetY, scale, CenterX, CenterY, angle, VelocityS,
308e41f4b71Sopenharmony_ci            angleR, repeat);
309e41f4b71Sopenharmony_ci    };
310e41f4b71Sopenharmony_ci    gestureApi->setGestureEventTarget(longPressGesture,
311e41f4b71Sopenharmony_ci                                      GESTURE_EVENT_ACTION_ACCEPT | GESTURE_EVENT_ACTION_UPDATE |
312e41f4b71Sopenharmony_ci                                            GESTURE_EVENT_ACTION_CANCEL,
313e41f4b71Sopenharmony_ci                                      column, onActionCallBackPanLongPress);
314e41f4b71Sopenharmony_ci
315e41f4b71Sopenharmony_ci    // Add the long press gesture to the gesture group.
316e41f4b71Sopenharmony_ci    if (gestureApi->addChildGesture) {
317e41f4b71Sopenharmony_ci        gestureApi->addChildGesture(groupGesture, longPressGesture);
318e41f4b71Sopenharmony_ci        OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "onPanActionCallBack, addChildGesture longPressGesture");
319e41f4b71Sopenharmony_ci    }
320e41f4b71Sopenharmony_ci    // Create a swipe gesture.
321e41f4b71Sopenharmony_ci    auto swipeGesture = gestureApi->createSwipeGesture(1, GESTURE_DIRECTION_ALL, 100);
322e41f4b71Sopenharmony_ci    if (gestureApi->getGestureType) {
323e41f4b71Sopenharmony_ci        ArkUI_GestureRecognizerType type = gestureApi->getGestureType(swipeGesture);
324e41f4b71Sopenharmony_ci        OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager",
325e41f4b71Sopenharmony_ci                     "onPanActionCallBack, ArkUI_GestureRecognizerType %{public}d", type);
326e41f4b71Sopenharmony_ci    }
327e41f4b71Sopenharmony_ci    // Set a callback for the swipe gesture.
328e41f4b71Sopenharmony_ci    auto onActionCallBack = [](ArkUI_GestureEvent *event, void *extraParam) {
329e41f4b71Sopenharmony_ci        ArkUI_GestureEventActionType actionType = OH_ArkUI_GestureEvent_GetActionType(event);
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_ci        float velocity = OH_ArkUI_PanGesture_GetVelocity(event);
332e41f4b71Sopenharmony_ci        float velocityX = OH_ArkUI_PanGesture_GetVelocityX(event);
333e41f4b71Sopenharmony_ci        float velocityY = OH_ArkUI_PanGesture_GetVelocityY(event);
334e41f4b71Sopenharmony_ci        float OffsetX = OH_ArkUI_PanGesture_GetOffsetX(event);
335e41f4b71Sopenharmony_ci        float OffsetY = OH_ArkUI_PanGesture_GetOffsetY(event);
336e41f4b71Sopenharmony_ci        float scale = OH_ArkUI_PinchGesture_GetScale(event);
337e41f4b71Sopenharmony_ci        float CenterX = OH_ArkUI_PinchGesture_GetCenterX(event);
338e41f4b71Sopenharmony_ci        float CenterY = OH_ArkUI_PinchGesture_GetCenterY(event);
339e41f4b71Sopenharmony_ci        float angle = OH_ArkUI_SwipeGesture_GetAngle(event);
340e41f4b71Sopenharmony_ci        float VelocityS = OH_ArkUI_SwipeGesture_GetVelocity(event);
341e41f4b71Sopenharmony_ci        float angleR = OH_ArkUI_RotationGesture_GetAngle(event);
342e41f4b71Sopenharmony_ci        float repeat = OH_ArkUI_LongPress_GetRepeatCount(event);
343e41f4b71Sopenharmony_ci
344e41f4b71Sopenharmony_ci
345e41f4b71Sopenharmony_ci        // Print logs.
346e41f4b71Sopenharmony_ci        OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager",
347e41f4b71Sopenharmony_ci                     "onPanActionCallBack, swipeGesture callback actionType: %{public}d, velocity "
348e41f4b71Sopenharmony_ci                     "%{public}f,velocityX "
349e41f4b71Sopenharmony_ci                     "%{public}f; "
350e41f4b71Sopenharmony_ci                     "velocityY %{public}f, OffsetX %{public}f, OffsetY %{public}f, scale %{public}fCenterX "
351e41f4b71Sopenharmony_ci                     "%{public}f CenterY"
352e41f4b71Sopenharmony_ci                     " %{public}f angle %{public}f VelocityS %{public}f angleR %{public}f repeat %{public}f",
353e41f4b71Sopenharmony_ci                     actionType, velocity, velocityX, velocityY, OffsetX, OffsetY, scale, CenterX, CenterY, angle,
354e41f4b71Sopenharmony_ci                     VelocityS, angleR, repeat);
355e41f4b71Sopenharmony_ci
356e41f4b71Sopenharmony_ci        ArkUI_NumberValue value[] = {{.f32 = 0}, {.f32 = 0}, {.f32 = 0}, {.f32 = angleR}, {.f32 = 0}};
357e41f4b71Sopenharmony_ci        ArkUI_AttributeItem item = {value, 5};
358e41f4b71Sopenharmony_ci        auto column = reinterpret_cast<ArkUI_NodeHandle>(extraParam);
359e41f4b71Sopenharmony_ci        nodeAPI->setAttribute(column, NODE_ROTATE, &item);
360e41f4b71Sopenharmony_ci    };
361e41f4b71Sopenharmony_ci
362e41f4b71Sopenharmony_ci    gestureApi->setGestureEventTarget(
363e41f4b71Sopenharmony_ci        swipeGesture, GESTURE_EVENT_ACTION_ACCEPT | GESTURE_EVENT_ACTION_UPDATE | GESTURE_EVENT_ACTION_END, column,
364e41f4b71Sopenharmony_ci        onActionCallBack);
365e41f4b71Sopenharmony_ci
366e41f4b71Sopenharmony_ci    // Add the swipe press gesture to the gesture group.
367e41f4b71Sopenharmony_ci    if (gestureApi->addChildGesture) {
368e41f4b71Sopenharmony_ci        gestureApi->addChildGesture(groupGesture, swipeGesture);
369e41f4b71Sopenharmony_ci        OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager",
370e41f4b71Sopenharmony_ci                     "onPanActionCallBack, addChildGesture swipeGesture");
371e41f4b71Sopenharmony_ci    }
372e41f4b71Sopenharmony_ci    // Set the gesture group to the component.
373e41f4b71Sopenharmony_ci    gestureApi->addGestureToNode(column, groupGesture, PRIORITY, NORMAL_GESTURE_MASK);
374e41f4b71Sopenharmony_ci    return column;
375e41f4b71Sopenharmony_ci}
376e41f4b71Sopenharmony_ci```
377e41f4b71Sopenharmony_ci
378e41f4b71Sopenharmony_ci
379e41f4b71Sopenharmony_ci### Exclusive Recognition
380e41f4b71Sopenharmony_ci
381e41f4b71Sopenharmony_ciFor combined gestures with exclusive recognition, the value of **ArkUI_GroupGestureMode** is **EXCLUSIVE_GROUP**. In this gesture recognition mode, all registered gestures are recognized at once. Once any of the gestures is recognized successfully, the gesture recognition ends, and recognition for all other gestures fails.
382e41f4b71Sopenharmony_ci
383e41f4b71Sopenharmony_ciThe following example illustrates the exclusive recognition of pan and pinch gestures:
384e41f4b71Sopenharmony_ci
385e41f4b71Sopenharmony_ci```
386e41f4b71Sopenharmony_ciArkUI_NodeHandle testGestureExample() {
387e41f4b71Sopenharmony_ci    auto column = nodeAPI->createNode(ARKUI_NODE_COLUMN);
388e41f4b71Sopenharmony_ci    auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON);
389e41f4b71Sopenharmony_ci
390e41f4b71Sopenharmony_ci    // Create a Column node.
391e41f4b71Sopenharmony_ci    ArkUI_NumberValue value[] = {{.u32 = 0xff112233}};
392e41f4b71Sopenharmony_ci    ArkUI_AttributeItem item = {value, 1};
393e41f4b71Sopenharmony_ci    nodeAPI->setAttribute(column, NODE_BACKGROUND_COLOR, &item);
394e41f4b71Sopenharmony_ci    ArkUI_NumberValue widthValue[] = {{200}};
395e41f4b71Sopenharmony_ci    ArkUI_AttributeItem width = {widthValue, 1};
396e41f4b71Sopenharmony_ci    nodeAPI->setAttribute(column, NODE_WIDTH, &width);
397e41f4b71Sopenharmony_ci    ArkUI_NumberValue heightValue[] = {{200}};
398e41f4b71Sopenharmony_ci    ArkUI_AttributeItem height = {heightValue, 1};
399e41f4b71Sopenharmony_ci    nodeAPI->setAttribute(column, NODE_HEIGHT, &height);
400e41f4b71Sopenharmony_ci
401e41f4b71Sopenharmony_ci    // Check for the gesture API.
402e41f4b71Sopenharmony_ci    auto gestureApi = reinterpret_cast<ArkUI_NativeGestureAPI_1 *>(
403e41f4b71Sopenharmony_ci        OH_ArkUI_QueryModuleInterfaceByName(ARKUI_NATIVE_GESTURE, "ArkUI_NativeGestureAPI_1"));
404e41f4b71Sopenharmony_ci    if (gestureApi->createGroupGesture) {
405e41f4b71Sopenharmony_ci        OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager",
406e41f4b71Sopenharmony_ci                     "onPanActionCallBack, createGroupGesture api exist");
407e41f4b71Sopenharmony_ci    } else {
408e41f4b71Sopenharmony_ci        OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager",
409e41f4b71Sopenharmony_ci                     "onPanActionCallBack, createGroupGesture api not exist");
410e41f4b71Sopenharmony_ci    }
411e41f4b71Sopenharmony_ci    auto groupGesture = gestureApi->createGroupGesture(ArkUI_GroupGestureMode::EXCLUSIVE_GROUP);
412e41f4b71Sopenharmony_ci
413e41f4b71Sopenharmony_ci    // Create a pan gesture.
414e41f4b71Sopenharmony_ci    auto panGesture = gestureApi->createPanGesture(1, GESTURE_DIRECTION_VERTICAL, 5);
415e41f4b71Sopenharmony_ci    if (gestureApi->getGestureType) {
416e41f4b71Sopenharmony_ci        ArkUI_GestureRecognizerType type = gestureApi->getGestureType(panGesture);
417e41f4b71Sopenharmony_ci        OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager",
418e41f4b71Sopenharmony_ci                     "onPanActionCallBack panGesture, ArkUI_GestureRecognizerType %{public}d", type);
419e41f4b71Sopenharmony_ci    }
420e41f4b71Sopenharmony_ci    // Set a callback for the pan gesture.
421e41f4b71Sopenharmony_ci    auto onActionCallBackPan = [](ArkUI_GestureEvent *event, void *extraParam) {
422e41f4b71Sopenharmony_ci        ArkUI_GestureEventActionType actionType = OH_ArkUI_GestureEvent_GetActionType(event);
423e41f4b71Sopenharmony_ci
424e41f4b71Sopenharmony_ci        float velocity = OH_ArkUI_PanGesture_GetVelocity(event);
425e41f4b71Sopenharmony_ci        float velocityX = OH_ArkUI_PanGesture_GetVelocityX(event);
426e41f4b71Sopenharmony_ci        float velocityY = OH_ArkUI_PanGesture_GetVelocityY(event);
427e41f4b71Sopenharmony_ci        float OffsetX = OH_ArkUI_PanGesture_GetOffsetX(event);
428e41f4b71Sopenharmony_ci        float OffsetY = OH_ArkUI_PanGesture_GetOffsetY(event);
429e41f4b71Sopenharmony_ci        float scale = OH_ArkUI_PinchGesture_GetScale(event);
430e41f4b71Sopenharmony_ci        float CenterX = OH_ArkUI_PinchGesture_GetCenterX(event);
431e41f4b71Sopenharmony_ci        float CenterY = OH_ArkUI_PinchGesture_GetCenterY(event);
432e41f4b71Sopenharmony_ci        float angle = OH_ArkUI_SwipeGesture_GetAngle(event);
433e41f4b71Sopenharmony_ci        float VelocityS = OH_ArkUI_SwipeGesture_GetVelocity(event);
434e41f4b71Sopenharmony_ci        float angleR = OH_ArkUI_RotationGesture_GetAngle(event);
435e41f4b71Sopenharmony_ci        float repeat = OH_ArkUI_LongPress_GetRepeatCount(event);
436e41f4b71Sopenharmony_ci
437e41f4b71Sopenharmony_ci        // Print logs.
438e41f4b71Sopenharmony_ci        OH_LOG_Print(
439e41f4b71Sopenharmony_ci            LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager",
440e41f4b71Sopenharmony_ci            "onPanActionCallBack, panGesture callback actionType: %{public}d, velocity %{public}f,velocityX "
441e41f4b71Sopenharmony_ci            "%{public}f; "
442e41f4b71Sopenharmony_ci            "velocityY %{public}f, OffsetX %{public}f, OffsetY %{public}f, scale %{public}fCenterX "
443e41f4b71Sopenharmony_ci            "%{public}f CenterY"
444e41f4b71Sopenharmony_ci            " %{public}f angle %{public}f VelocityS %{public}f angleR %{public}f repeat %{public}f",
445e41f4b71Sopenharmony_ci            actionType, velocity, velocityX, velocityY, OffsetX, OffsetY, scale, CenterX, CenterY, angle, VelocityS,
446e41f4b71Sopenharmony_ci            angleR, repeat);
447e41f4b71Sopenharmony_ci    };
448e41f4b71Sopenharmony_ci    gestureApi->setGestureEventTarget(panGesture,
449e41f4b71Sopenharmony_ci                                      GESTURE_EVENT_ACTION_ACCEPT | GESTURE_EVENT_ACTION_UPDATE |
450e41f4b71Sopenharmony_ci                                          GESTURE_EVENT_ACTION_END | GESTURE_EVENT_ACTION_CANCEL,
451e41f4b71Sopenharmony_ci                                      column, onActionCallBackPan);
452e41f4b71Sopenharmony_ci    // Add the pan press gesture to the gesture group.
453e41f4b71Sopenharmony_ci    if (gestureApi->addChildGesture) {
454e41f4b71Sopenharmony_ci        gestureApi->addChildGesture(groupGesture, panGesture);
455e41f4b71Sopenharmony_ci        OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "onPanActionCallBack, addChildGesture panGesture");
456e41f4b71Sopenharmony_ci    }
457e41f4b71Sopenharmony_ci    // Create a pinch gesture.
458e41f4b71Sopenharmony_ci    auto pinchGesture = gestureApi->createPinchGesture(0, 0);
459e41f4b71Sopenharmony_ci    if (gestureApi->getGestureType) {
460e41f4b71Sopenharmony_ci        ArkUI_GestureRecognizerType type = gestureApi->getGestureType(pinchGesture);
461e41f4b71Sopenharmony_ci        OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager",
462e41f4b71Sopenharmony_ci                     "onPanActionCallBack pinchGesture, ArkUI_GestureRecognizerType %{public}d", type);
463e41f4b71Sopenharmony_ci    }
464e41f4b71Sopenharmony_ci    // Set a callback for the pinch gesture.
465e41f4b71Sopenharmony_ci    auto onActionCallBack = [](ArkUI_GestureEvent *event, void *extraParam) {
466e41f4b71Sopenharmony_ci        ArkUI_GestureEventActionType actionType = OH_ArkUI_GestureEvent_GetActionType(event);
467e41f4b71Sopenharmony_ci
468e41f4b71Sopenharmony_ci        float velocity = OH_ArkUI_PanGesture_GetVelocity(event);
469e41f4b71Sopenharmony_ci        float velocityX = OH_ArkUI_PanGesture_GetVelocityX(event);
470e41f4b71Sopenharmony_ci        float velocityY = OH_ArkUI_PanGesture_GetVelocityY(event);
471e41f4b71Sopenharmony_ci        float OffsetX = OH_ArkUI_PanGesture_GetOffsetX(event);
472e41f4b71Sopenharmony_ci        float OffsetY = OH_ArkUI_PanGesture_GetOffsetY(event);
473e41f4b71Sopenharmony_ci        float scale = OH_ArkUI_PinchGesture_GetScale(event);
474e41f4b71Sopenharmony_ci        float CenterX = OH_ArkUI_PinchGesture_GetCenterX(event);
475e41f4b71Sopenharmony_ci        float CenterY = OH_ArkUI_PinchGesture_GetCenterY(event);
476e41f4b71Sopenharmony_ci        float angle = OH_ArkUI_SwipeGesture_GetAngle(event);
477e41f4b71Sopenharmony_ci        float VelocityS = OH_ArkUI_SwipeGesture_GetVelocity(event);
478e41f4b71Sopenharmony_ci        float angleR = OH_ArkUI_RotationGesture_GetAngle(event);
479e41f4b71Sopenharmony_ci        float repeat = OH_ArkUI_LongPress_GetRepeatCount(event);
480e41f4b71Sopenharmony_ci
481e41f4b71Sopenharmony_ci
482e41f4b71Sopenharmony_ci        OH_LOG_Print(
483e41f4b71Sopenharmony_ci            LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager",
484e41f4b71Sopenharmony_ci            "onPanActionCallBack, pinchGesture callback actionType: %{public}d, velocity %{public}f,velocityX "
485e41f4b71Sopenharmony_ci            "%{public}f; "
486e41f4b71Sopenharmony_ci            "velocityY %{public}f, OffsetX %{public}f, OffsetY %{public}f, scale %{public}fCenterX "
487e41f4b71Sopenharmony_ci            "%{public}f CenterY"
488e41f4b71Sopenharmony_ci            " %{public}f angle %{public}f VelocityS %{public}f angleR %{public}f repeat %{public}f",
489e41f4b71Sopenharmony_ci            actionType, velocity, velocityX, velocityY, OffsetX, OffsetY, scale, CenterX, CenterY, angle, VelocityS,
490e41f4b71Sopenharmony_ci            angleR, repeat);
491e41f4b71Sopenharmony_ci
492e41f4b71Sopenharmony_ci
493e41f4b71Sopenharmony_ci        ArkUI_NumberValue value[] = {{.f32 = scale}, {.f32 = scale}};
494e41f4b71Sopenharmony_ci        ArkUI_AttributeItem item = {value, 2};
495e41f4b71Sopenharmony_ci        auto column = reinterpret_cast<ArkUI_NodeHandle>(extraParam);
496e41f4b71Sopenharmony_ci        nodeAPI->setAttribute(column, NODE_SCALE, &item);
497e41f4b71Sopenharmony_ci    };
498e41f4b71Sopenharmony_ci    gestureApi->setGestureEventTarget(pinchGesture,
499e41f4b71Sopenharmony_ci                                      GESTURE_EVENT_ACTION_ACCEPT | GESTURE_EVENT_ACTION_UPDATE |
500e41f4b71Sopenharmony_ci                                          GESTURE_EVENT_ACTION_END | GESTURE_EVENT_ACTION_CANCEL,
501e41f4b71Sopenharmony_ci                                      column, onActionCallBack);
502e41f4b71Sopenharmony_ci    // Add the pinch press gesture to the gesture group.
503e41f4b71Sopenharmony_ci    if (gestureApi->addChildGesture) {
504e41f4b71Sopenharmony_ci        gestureApi->addChildGesture(groupGesture, pinchGesture);
505e41f4b71Sopenharmony_ci        OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Manager", "onPanActionCallBack, addChildGesture pinchGesture");
506e41f4b71Sopenharmony_ci    }
507e41f4b71Sopenharmony_ci    // Set the gesture group to the component.
508e41f4b71Sopenharmony_ci    gestureApi->addGestureToNode(column, groupGesture, PRIORITY, NORMAL_GESTURE_MASK);
509e41f4b71Sopenharmony_ci    return column;
510e41f4b71Sopenharmony_ci}
511e41f4b71Sopenharmony_ci```
512e41f4b71Sopenharmony_ci
513e41f4b71Sopenharmony_ci
514e41f4b71Sopenharmony_ci### Custom Gesture Judgment
515e41f4b71Sopenharmony_ci
516e41f4b71Sopenharmony_ciWith support for custom gesture judgment, you can determine whether to continue executing a gesture based on callback content.
517e41f4b71Sopenharmony_ci
518e41f4b71Sopenharmony_ciTo implement custom gesture judgment, adjust the example of binding gesture events as follows:
519e41f4b71Sopenharmony_ci
520e41f4b71Sopenharmony_ci
521e41f4b71Sopenharmony_ci1. Create a custom gesture judgment callback.
522e41f4b71Sopenharmony_ci   ```
523e41f4b71Sopenharmony_ci       auto onInterruptCallback = [](ArkUI_GestureInterruptInfo *info) -> ArkUI_GestureInterruptResult {
524e41f4b71Sopenharmony_ci           // Check whether the gesture is a system gesture.
525e41f4b71Sopenharmony_ci           auto systag = OH_ArkUI_GestureInterruptInfo_GetSystemFlag(info);
526e41f4b71Sopenharmony_ci           // Obtain the gesture recognizer for gesture interception.
527e41f4b71Sopenharmony_ci           auto recognizer = OH_ArkUI_GestureInterruptInfo_GetRecognizer(info);
528e41f4b71Sopenharmony_ci           // Obtain the system gesture type.
529e41f4b71Sopenharmony_ci           auto systemRecognizerType = OH_ArkUI_GestureInterruptInfo_GetSystemRecognizerType(info);
530e41f4b71Sopenharmony_ci           // Obtain the gesture event.
531e41f4b71Sopenharmony_ci           auto gestureEvent = OH_ArkUI_GestureInterruptInfo_GetGestureEvent(info);
532e41f4b71Sopenharmony_ci           auto inputevent = OH_ArkUI_GestureEvent_GetRawInputEvent(gestureEvent);
533e41f4b71Sopenharmony_ci   
534e41f4b71Sopenharmony_ci           if (systag) {
535e41f4b71Sopenharmony_ci               // If the gesture is a system gesture, do not intercept it.
536e41f4b71Sopenharmony_ci               return GESTURE_INTERRUPT_RESULT_CONTINUE;
537e41f4b71Sopenharmony_ci           } else {
538e41f4b71Sopenharmony_ci               // If the gesture is not a system gesture, intercept and reject it.
539e41f4b71Sopenharmony_ci               return GESTURE_INTERRUPT_RESULT_REJECT;
540e41f4b71Sopenharmony_ci           }
541e41f4b71Sopenharmony_ci       };
542e41f4b71Sopenharmony_ci   ```
543e41f4b71Sopenharmony_ci
544e41f4b71Sopenharmony_ci2. Bind the custom gesture interrupter to the node.
545e41f4b71Sopenharmony_ci   ```
546e41f4b71Sopenharmony_ci   gestureApi->setGestureInterrupterToNode(column, onInterruptCallback);
547e41f4b71Sopenharmony_ci   ```
548e41f4b71Sopenharmony_ci
549e41f4b71Sopenharmony_ci
550e41f4b71Sopenharmony_ciAfter the aforementioned modifications, the originally effective long press gesture is intercepted. Consequently, long pressing on the **Column** node will no longer trigger the long press gesture callback.
551