1# Drag Event 2 3The ArkUI framework provides a set of drag event APIs to help you implement drag-and-drop functionality. These events include [NODE_ON_PRE_DRAG](../reference/apis-arkui/_ark_u_i___native_module.md#arkui_nodeeventtype), [NODE_ON_DRAG_START](../reference/apis-arkui/_ark_u_i___native_module.md#arkui_nodeeventtype), [NODE_ON_DROP](../reference/apis-arkui/_ark_u_i___native_module.md#arkui_nodeeventtype), [NODE_ON_DRAG_ENTER](../reference/apis-arkui/_ark_u_i___native_module.md#arkui_nodeeventtype), [NODE_ON_DRAG_MOVE](../reference/apis-arkui/_ark_u_i___native_module.md#arkui_nodeeventtype), [NODE_ON_DRAG_LEAVE](../reference/apis-arkui/_ark_u_i___native_module.md#arkui_nodeeventtype), and [NODE_ON_DRAG_END](../reference/apis-arkui/_ark_u_i___native_module.md#arkui_nodeeventtype). These events are triggered at different stages of the drag operation, allowing you to perform specific actions and manage the drag interaction as needed. 4 5## Basic Drag Implementation 6 7In ArkUI, you can implement the drag-and-drop functionality using C and C++ by calling C APIs. The following provides step-by-step instructions using the **Image** component as an example, along with key points to keep in mind during development. 8 91. Set a component draggable. 10 11 Obtain the [Node-API](../reference/apis-arkui/_ark_u_i___native_module.md#oh_arkui_getmoduleinterface), which you'll need for node operations, such as creating a node. 12 13 ```cpp 14 ArkUI_NativeNodeAPI_1 *nodeAPI = nullptr; 15 OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); 16 ``` 17 18 Create an **Image** node and set the draggable and other related attributes. 19 20 ```cpp 21 auto image = nodeAPI->createNode(ARKUI_NODE_IMAGE); 22 ArkUI_NumberValue NODE_IMAGE_SRC_Item = {.string = "/pages/common/1111.png"}; 23 ArkUI_NumberValue imageWidthValue[] = {100}; 24 ArkUI_AttributeItem imageWidthItem = {imageWidthValue, 1}; 25 ArkUI_NumberValue imageHeightValue[] = {100}; 26 ArkUI_AttributeItem imageHeightItem = {imageHeightValue, 1}; 27 ArkUI_NumberValue marginValue[] = {20}; 28 ArkUI_AttributeItem marginItem = {marginValue, 1}; 29 nodeAPI->setAttribute(image, NODE_WIDTH, &imageWidthItem); 30 nodeAPI->setAttribute(image, NODE_HEIGHT, &imageHeightItem); 31 nodeAPI->setAttribute(image, NODE_IMAGE_SRC, &NODE_IMAGE_SRC_Item); 32 nodeAPI->setAttribute(image, NODE_MARGIN, &marginItem); 33 nodeAPI->registerNodeEvent(image, NODE_ON_DRAG_START, 1, nullptr); 34 auto returnValue1 = OH_ArkUI_SetNodeDraggable(image, true); 35 ``` 36 372. Customize the drag preview and background image. 38 39 Create a [PixelMap](../reference/apis-image-kit/_image___native_module.md#oh_pixelmapnative_createpixelmap) object and set its width, height, and other properties. Set [dragPreviewOption](../reference/apis-arkui/drag__and__drop_8h.md#functions) for the **Image** node to customize the rounded corners and badges of the drag preview. 40 41 ```cpp 42 // Create a PixelMap. 43 uint8_t data[960000]; 44 size_t dataSize = 960000; 45 for (int i = 0; i < dataSize; i++) { 46 data[i] = i + 1; 47 } 48 // Create a parameter structure instance and set parameters. 49 OH_Pixelmap_InitializationOptions *createOpts; 50 OH_PixelmapInitializationOptions_Create(&createOpts); 51 OH_PixelmapInitializationOptions_SetWidth(createOpts, 400); 52 OH_PixelmapInitializationOptions_SetHeight(createOpts, 600); 53 OH_PixelmapInitializationOptions_SetPixelFormat(createOpts, PIXEL_FORMAT_BGRA_8888); 54 OH_PixelmapInitializationOptions_SetAlphaType(createOpts, PIXELMAP_ALPHA_TYPE_UNKNOWN); 55 // Create a Pixelmap instance. 56 OH_PixelmapNative *pixelmap = nullptr; 57 OH_PixelmapNative_CreatePixelmap(data, dataSize, createOpts, &pixelmap); 58 OH_PixelmapNative_Rotate(pixelmap, 45); 59 OH_PixelmapNative_Opcity(pixelmap, 0.1); 60 OH_PixelmapNative_Scale(pixelmap, 0.5, 1.0); 61 OH_PixelmapNative_Translate(pixelmap, 50.0, 10.0); 62 OH_ArkUI_SetNodeDragPreview(image, pixelmap); 63 auto *previewOptions = OH_ArkUI_CreateDragPreviewOption(); 64 auto returnValue2 = OH_ArkUI_DragPreviewOption_SetNumberBadgeEnabled(previewOptions, true); 65 auto returnValue3 = OH_ArkUI_DragPreviewOption_SetBadgeNumber(previewOptions, 10); 66 auto returnValue4 = OH_ArkUI_DragPreviewOption_SetDefaultRadiusEnabled(previewOptions, true); 67 OH_ArkUI_SetNodeDragPreviewOption(image, previewOptions); 68 ``` 69 703. Set related events. 71 72 Use a unified callback to handle events. Distinguish between different events using [eventType](../reference/apis-arkui/_ark_u_i___native_module.md#arkui_nodeeventtype). 73 74 ```cpp 75 nodeAPI->registerNodeEventReceiver([](ArkUI_NodeEvent *event) { 76 auto eventType = OH_ArkUI_NodeEvent_GetEventType(event); 77 auto targetId = OH_ArkUI_NodeEvent_GetTargetId(event); 78 auto *dragEvent = OH_ArkUI_NodeEvent_GetDragEvent(event); 79 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 80 "targetId=%{public}d,eventType=%{public}d,", targetId, 81 eventType); 82 switch (eventType) { 83 case NODE_ON_CLICK: { 84 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 85 "ARKUI_NODE_BUTTON click! dragable"); 86 break; 87 } 88 case NODE_ON_PRE_DRAG: { 89 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", "NODE_ON_PRE_DRAG EventReceiver"); 90 break; 91 } 92 case NODE_ON_DRAG_START: { 93 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 94 "NODE_ON_DRAG_START EventReceiver"); 95 break; 96 } 97 case NODE_ON_DROP: { 98 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", "NODE_ON_DROP EventReceiver"); 99 break; 100 } 101 case NODE_ON_DRAG_ENTER: { 102 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 103 "NODE_ON_DRAG_ENTER EventReceiver"); 104 break; 105 } 106 case NODE_ON_DRAG_MOVE: { 107 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 108 "NODE_ON_DRAG_MOVE EventReceiver"); 109 break; 110 } 111 case NODE_ON_DRAG_LEAVE: { 112 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 113 "NODE_ON_DRAG_LEAVE EventReceiver"); 114 break; 115 } 116 case NODE_ON_DRAG_END: { 117 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", "NODE_ON_DRAG_END EventReceiver"); 118 break; 119 } 120 } 121 }); 122 ``` 123 1244. Handle the **NODE_ON_DRAG_START** event. 125 126 In the **NODE_ON_DRAG_START** event, perform operations required to initiate the drag operation, typically involving data processing. For example, create a [UdmfRecord](../reference/apis-arkdata/_u_d_m_f.md#oh_udmfrecord), add the required data (such as **imageUri**) to the **UdmfRecord** in the **fileUri** type, set the **UdmfRecord** to [udmfData](../reference/apis-arkdata/_u_d_m_f.md#oh_udmfdata), and set **udmfData** to [DragEvent](../reference/apis-arkui/_ark_u_i___native_module.md#arkui_dragevent). 127 128 ```cpp 129 case NODE_ON_DRAG_START: { 130 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 131 "NODE_ON_DRAG_START EventReceiver"); 132 OH_UdmfRecord *record = OH_UdmfRecord_Create(); 133 int returnValue; 134 OH_UdsFileUri *imageValue = OH_UdsFileUri_Create(); 135 returnValue = OH_UdsFileUri_SetFileUri(imageValue, "/pages/common/1111.png"); 136 returnValue = OH_UdmfRecord_AddFileUri(record, imageValue); 137 OH_UdmfData *data = OH_UdmfData_Create(); 138 returnValue = OH_UdmfData_AddRecord(data, record); 139 returnVaule = OH_ArkUI_DragEvent_SetData(dragEvent, data); 140 break; 141 } 142 ``` 143 1445. Handle the **NODE_ON_DROP** event. 145 146 In the **NODE_ON_DROP** event, perform operations related to the drop phase, typically involving retrieving the data passed during the drag process. For example, obtain [udmfData](../reference/apis-arkdata/_u_d_m_f.md#oh_udmfdata), check whether the required data type exists, extract the corresponding data from [UdmfRecord](../reference/apis-arkdata/_u_d_m_f.md#oh_udmfrecord), and destroy the pointer. 147 148 ```cpp 149 case NODE_ON_DROP: { 150 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 151 "NODE_ON_DRAG_START EventReceiver"); 152 // Obtain the UDMF data. 153 int returnValue; 154 // Create an OH_UdmfData object. 155 OH_UdmfData *data = OH_UdmfData_Create(); 156 returnValue = OH_ArkUI_DragEvent_GetUdmfData(dragEvent, data); 157 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 158 "OH_ArkUI_DragEvent_GetUdmfData returnValue = %{public}d", returnValue); 159 // Check whether OH_UdmfData has the required data type. 160 bool resultUdmf = OH_UdmfData_HasType(data, UDMF_META_GENERAL_FILE); 161 if (resultUdmf) { 162 // Obtain records from OH_UdmfData. 163 unsigned int recordsCount = 0; 164 OH_UdmfRecord **records = OH_UdmfData_GetRecords(data, &recordsCount); 165 // Extract elements from records. 166 int returnStatus; 167 for (int i = 0; i < recordsCount; i++) { 168 // Obtain the file type data from OH_UdmfRecord. 169 OH_UdsFileUri *imageValue = OH_UdsFileUri_Create(); 170 returnStatus = OH_UdmfRecord_GetFileUri(records[i], imageValue); 171 const char* fileUri = OH_UdsFileUri_GetFileUri(imageValue); 172 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 173 "dragTest OH_UdmfRecord_GetPlainText " 174 "returnStatus= %{public}d " 175 "fileUri= %{public}s", 176 returnStatus, fileUri); 177 // Destroy the pointer after use. 178 OH_UdsFileUri_Destroy(imageValue); 179 } 180 } else { 181 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 182 "OH_UdmfData_HasType not contain UDMF_META_PLAIN_TEXT"); 183 } 184 break; 185 } 186 ``` 187 188## Initiating a Drag Operation 189 190In addition to the basic drag-and-drop functionality, ArkUI allows you to initiate a drag operation using C APIs. The following example demonstrates how to use C APIs to start a drag operation with text data and highlights key points to keep in mind during development. 191 1921. Register node events. 193 194 Create a **Button** node, set its attributes, and register the [NODE_ON_TOUCH_INTERCEPT](../reference/apis-arkui/_ark_u_i___native_module.md#arkui_nodeeventtype) event. 195 196 ```cpp 197 // Use buttonTouch as targetId to distinguish events from different targets. 198 enum { 199 buttonTouch 200 } 201 202 ArkUI_NativeNodeAPI_1 *nodeAPI = nullptr; 203 OH_ArkUI_GetModuleInterface(ARKUI_NATIVE_NODE, ArkUI_NativeNodeAPI_1, nodeAPI); 204 auto button = nodeAPI->createNode(ARKUI_NODE_BUTTON); 205 ArkUI_AttributeItem NODE_Button_SRC_Item = {.string = "button"}; 206 ArkUI_NumberValue buttonWidthValue[] = {200}; 207 ArkUI_AttributeItem buttonWidthItem = {buttonWidthValue, 1}; 208 ArkUI_NumberValue buttonHeightValue[] = {100}; 209 ArkUI_AttributeItem buttonHeightItem = {buttonHeightValue, 1}; 210 ArkUI_NumberValue marginValue[] = {20}; 211 ArkUI_AttributeItem marginItem = {marginValue, 1}; 212 nodeAPI->setAttribute(button, NODE_WIDTH, &buttonWidthItem); 213 nodeAPI->setAttribute(button, NODE_HEIGHT, &buttonHeightItem); 214 nodeAPI->setAttribute(button, NODE_MARGIN, &marginItem); 215 nodeAPI->setAttribute(button, NODE_BUTTON_LABEL, &NODE_Button_SRC_Item); 216 nodeAPI->registerNodeEvent(button, NODE_ON_TOUCH_INTERCEPT, buttonTouch, nullptr); 217 ``` 2182. Receive the **NODE_ON_TOUCH_INTERCEPT** event. 219 220 In the **NODE_ON_TOUCH_INTERCEPT** event, you need to set up **DragAction** to initiate the drag operation. Use [targetId](../reference/apis-arkui/_ark_u_i___native_module.md#oh_arkui_nodeevent_gettargetid) to distinguish events triggered by different buttons. 221 222 ```cpp 223 nodeAPI->registerNodeEventReceiver([](ArkUI_NodeEvent *event) { 224 auto eventType = OH_ArkUI_NodeEvent_GetEventType(event); 225 auto targetId = OH_ArkUI_NodeEvent_GetTargetId(event); 226 ArkUI_NodeHandle node = OH_ArkUI_NodeEvent_GetNodeHandle(event); 227 auto *dragEvent = OH_ArkUI_NodeEvent_GetDragEvent(event); 228 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 229 "targetId=%{public}d,eventType=%{public}d,", targetId, 230 eventType); 231 switch (eventType) { 232 case NODE_ON_TOUCH_INTERCEPT: { 233 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 234 "ARKUI_NODE_BUTTON touch intercept"); 235 break; 236 switch (targetId) { 237 case buttonTouch: { 238 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", "dragTest button touch!"); 239 } 240 } 241 } 242 case NODE_ON_DROP: { 243 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", "NODE_ON_DROP EventReceiver"); 244 } 245 } 246 }); 247 ``` 2483. Set the drag action. 249 250 In the **NODE_ON_TOUCH_INTERCEPT** event, set **DragAction** to initiate the drag operation. Create a [PixelMap](../reference/apis-image-kit/_image___native_module.md#oh_pixelmapnative_createpixelmap), set [dragPreviewOption](../reference/apis-arkui/drag__and__drop_8h.md#functions) and the touch point, and set the text data for the drag operation. 251 252 ```cpp 253 case NODE_ON_TOUCH_INTERCEPT: { 254 // Set a PixelMap object. 255 uint8_t data[960000]; 256 size_t dataSize = 960000; 257 for (int i = 0; i < dataSize; i++) { 258 data[i] = i + 1; 259 } 260 // Create a parameter structure instance and set parameters. 261 OH_Pixelmap_InitializationOptions *createOpts; 262 OH_PixelmapInitializationOptions_Create(&createOpts); 263 OH_PixelmapInitializationOptions_SetWidth(createOpts, 200); 264 OH_PixelmapInitializationOptions_SetHeight(createOpts, 300); 265 OH_PixelmapInitializationOptions_SetPixelFormat(createOpts, PIXEL_FORMAT_BGRA_8888); 266 OH_PixelmapInitializationOptions_SetAlphaType(createOpts, PIXELMAP_ALPHA_TYPE_UNKNOWN); 267 // Create a Pixelmap instance. 268 OH_PixelmapNative *pixelmap = nullptr; 269 OH_PixelmapNative_CreatePixelmap(data, dataSize, createOpts, &pixelmap); 270 OH_PixelmapNative_Rotate(pixelmap, 90.0); 271 OH_PixelmapNative_Opacity(pixelmap, 0.2); 272 OH_PixelmapNative_Scale(pixelmap, 0.8, 1.0); 273 OH_PixelmapNative_Flip(pixelmap, true, true); 274 std::vector<OH_PixelmapNative *> pixelVector; 275 pixelVector.push_back(pixelmap); 276 int returnValue; 277 switch (targetId) { 278 case buttonTouch: { 279 // CreateDragAction 280 auto action1 = OH_ArkUI_CreateDragActionWithNode(node); 281 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 282 "OH_ArkUI_CreateDragActionWithNode returnValue = %{public}p", action1); 283 returnValue = 284 OH_ArkUI_DragAction_SetPixelMaps(action1, pixelVector.data(), pixelVector.size()); 285 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 286 "OH_ArkUI_DragAction_SetPixelMaps returnValue = %{public}d", returnValue); 287 // Set DragPreviewOption. 288 auto *previewOptions1 = OH_ArkUI_CreateDragPreviewOption(); 289 OH_ArkUI_DragPreviewOption_SetScaleMode( 290 previewOptions1, ArkUI_DragPreviewScaleMode::ARKUI_DRAG_PREVIEW_SCALE_DISABLED); 291 OH_ArkUI_DragPreviewOption_SetDefaultShadowEnabled(previewOptions1, true); 292 OH_ArkUI_DragPreviewOption_SetDefaultRadiusEnabled(previewOptions1, true); 293 returnValue = OH_ArkUI_DragAction_SetDragPreviewOption(action1, previewOptions1); 294 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 295 "OH_ArkUI_DragAction_SetDragPreviewOption returnValue = %{public}d", 296 returnValue); 297 // Set pointerId. 298 returnValue = OH_ArkUI_DragAction_SetPointerId(action1, 0); //-1 0 10 299 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 300 "OH_ArkUI_DragAction_SetPointerId returnValue = %{public}d", returnValue); 301 // Set the touch point. 302 returnValue = OH_ArkUI_DragAction_SetTouchPointX(action1, 200); //-1 0 200 303 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 304 "OH_ArkUI_DragAction_SetTouchPointX returnValue = %{public}d", returnValue); 305 returnValue = OH_ArkUI_DragAction_SetTouchPointY(action1, 200); //-1 0 200 306 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 307 "OH_ArkUI_DragAction_SetTouchPointY returnValue = %{public}d", returnValue); 308 // Set unifiedData. 309 // Create an OH_UdmfRecord object. 310 OH_UdmfRecord *record = OH_UdmfRecord_Create(); 311 // Add plain text data to OH_UdmfRecord. 312 OH_UdsPlainText *plainText = OH_UdsPlainText_Create(); 313 int returnStatus; 314 OH_UdsPlainText_SetAbstract(plainText, "this is plainText Abstract example"); 315 OH_UdsPlainText_SetContent(plainText, "this is plainText Content example"); 316 returnStatus = OH_UdmfRecord_AddPlainText(record, plainText); 317 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 318 "dragTest OH_UdmfRecord_AddPlainText returnStatus = %{public}d", returnStatus); 319 // Create an OH_UdmfData object. 320 OH_UdmfData *data = OH_UdmfData_Create(); 321 // Add OH_UdmfRecord to OH_UdmfData. 322 returnStatus = OH_UdmfData_AddRecord(data, record); 323 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 324 "dragTest OH_UdmfData_AddRecord returnStatus = %{public}d", returnStatus); 325 returnValue = OH_ArkUI_DragAction_SetData(action1, data); 326 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 327 "OH_ArkUI_DragAction_SetData returnValue = %{public}d", returnValue); 328 // startDrag 329 returnValue = OH_ArkUI_StartDrag(action1); 330 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 331 "OH_ArkUI_StartDrag returnValue = %{public}d", returnValue); 332 OH_ArkUI_DragAction_Dispose(action1); 333 } 334 } 335 } 336 ``` 3374. Handle the **NODE_ON_DROP** event. 338 339 In the **NODE_ON_DROP** event, perform actions related to the drop phase. Typically, this involves obtaining the data passed during the drag operation. The drag data from **DragAction** is also obtained through **DragEvent** 340 341 ```cpp 342 case NODE_ON_DROP: { 343 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", "NODE_ON_DROP EventReceiver"); 344 // Obtain the UDMF data. 345 int returnValue; 346 // Create an OH_UdmfData object. 347 OH_UdmfData *data = OH_UdmfData_Create(); 348 returnValue = OH_ArkUI_DragEvent_GetUdmfData(dragEvent, data); 349 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 350 "OH_ArkUI_DragEvent_GetUdmfData returnValue = %{public}d", returnValue); 351 // Check whether OH_UdmfData has the required data type. 352 bool resultUdmf = OH_UdmfData_HasType(data, UDMF_META_PLAIN_TEXT); 353 if (resultUdmf) { 354 // Obtain records from OH_UdmfData. 355 unsigned int recordsCount = 0; 356 OH_UdmfRecord **records = OH_UdmfData_GetRecords(data, &recordsCount); 357 // Extract elements from records. 358 int returnStatus; 359 for (int i = 0; i < recordsCount; i++) { 360 // Obtain plain text data from OH_UdmfRecord. 361 OH_UdsPlainText *plainTextValue = OH_UdsPlainText_Create(); 362 returnStatus = OH_UdmfRecord_GetPlainText(records[i], plainTextValue); 363 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 364 "dragTest OH_UdmfRecord_GetPlainText " 365 "returnStatus= %{public}d", 366 returnStatus); 367 auto getAbstract = OH_UdsPlainText_GetAbstract(plainTextValue); 368 auto getContent = OH_UdsPlainText_GetContent(plainTextValue); 369 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 370 "OH_UdsPlainText_GetAbstract = " 371 "%{public}s, OH_UdsPlainText_GetContent = " 372 "%{public}s", 373 getAbstract, getContent); 374 // Destroy the pointer after use. 375 OH_UdsPlainText_Destroy(plainTextValue); 376 } 377 } else { 378 OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "dragTest", 379 "OH_UdmfData_HasType not contain UDMF_META_PLAIN_TEXT"); 380 } 381 break; 382 } 383 ``` 384<!--no_check-->