!39643 修改OH_ArkUI_DragEvent_GetUdmfData接口不能获取数据的问题

Merge pull request !39643 from Zhang Jinyu/0805
This commit is contained in:
openharmony_ci 2024-08-05 09:08:18 +00:00 committed by Gitee
commit 189536e4e7
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 13 additions and 3 deletions

View File

@ -225,6 +225,7 @@ struct ArkUIMouseEvent {
struct ArkUIDragEvent {
void* unifiedData;
void* unifiedDataSummary;
bool isSuitGetData;
ArkUI_Int32 dragResult;
ArkUI_Float64 touchPointX;
ArkUI_Float64 touchPointY;

View File

@ -135,6 +135,7 @@ void SetOnDragDrop(ArkUINodeHandle node, void* extraParam)
std::vector<std::string> keepStr(summary.size());
SetDragEventProperty(info, event, strList, keepStr);
event.dragEvent.isSuitGetData = true;
auto unifiedData = UdmfClient::GetInstance()->TransformUnifiedDataPtr(info->GetData());
@ -167,6 +168,7 @@ void SetOnDragStart(ArkUINodeHandle node, void* extraParam)
std::vector<std::string> keepStr(summary.size());
SetDragEventProperty(info, event, strList, keepStr);
event.dragEvent.isSuitGetData = false;
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
SendArkUIAsyncEvent(&event);
@ -201,6 +203,7 @@ void SetOnDragEnter(ArkUINodeHandle node, void* extraParam)
auto unifiedData = UdmfClient::GetInstance()->TransformUnifiedDataPtr(info->GetData());
event.dragEvent.dragBehavior = static_cast<ArkUI_Int32>(DragBehavior::UNKNOWN);
event.dragEvent.unifiedData = unifiedData;
event.dragEvent.isSuitGetData = false;
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
SendArkUIAsyncEvent(&event);
@ -231,6 +234,8 @@ void SetOnDragMove(ArkUINodeHandle node, void* extraParam)
auto unifiedData = UdmfClient::GetInstance()->TransformUnifiedDataPtr(info->GetData());
event.dragEvent.dragBehavior = static_cast<ArkUI_Int32>(DragBehavior::UNKNOWN);
event.dragEvent.unifiedData = unifiedData;
event.dragEvent.isSuitGetData = false;
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
SendArkUIAsyncEvent(&event);
info->SetResult(static_cast<DragRet>(event.dragEvent.dragResult));
@ -261,6 +266,8 @@ void SetOnDragLeave(ArkUINodeHandle node, void* extraParam)
auto unifiedData = UdmfClient::GetInstance()->TransformUnifiedDataPtr(info->GetData());
event.dragEvent.dragBehavior = static_cast<ArkUI_Int32>(DragBehavior::UNKNOWN);
event.dragEvent.unifiedData = unifiedData;
event.dragEvent.isSuitGetData = false;
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
SendArkUIAsyncEvent(&event);
info->SetResult(static_cast<DragRet>(event.dragEvent.dragResult));
@ -301,6 +308,7 @@ void SetOnDragEnd(ArkUINodeHandle node, void* extraParam)
auto unifiedData = UdmfClient::GetInstance()->TransformUnifiedDataPtr(info->GetData());
event.dragEvent.unifiedData = unifiedData;
event.dragEvent.isSuitGetData = false;
// Did NOT define pressCode, so will NOT pass presscode to UI.
event.dragEvent.dragResult = static_cast<ArkUI_Int32>(info->GetResult());
@ -326,6 +334,8 @@ void SetOnPreDrag(ArkUINodeHandle node, void* extraParam)
// Did NOT define pressCode, so will NOT pass presscode to UI.
event.componentAsyncEvent.data[0].i32 = static_cast<ArkUI_Int32>(preDragStatus);
event.dragEvent.isSuitGetData = false;
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
SendArkUIAsyncEvent(&event);
};

View File

@ -70,9 +70,8 @@ int32_t OH_ArkUI_DragEvent_GetUdmfData(ArkUI_DragEvent* event, OH_UdmfData* data
if (!event || !dragEvent || (dragEvent->unifiedData == nullptr) || !data) {
return ARKUI_ERROR_CODE_PARAM_INVALID;
}
auto rawData = reinterpret_cast<OH_UdmfData*>(dragEvent->unifiedData);
auto raw = dynamic_cast<OH_UdmfData*>(rawData);
if (raw) {
if (!(dragEvent->isSuitGetData)) {
return ARKUI_ERROR_CODE_PARAM_INVALID;
}
auto unifiedData =