!39120 修改拖拽事件的capi接口

Merge pull request !39120 from Zhang Jinyu/lst
This commit is contained in:
openharmony_ci 2024-07-31 03:18:50 +00:00 committed by Gitee
commit 4c3a64de63
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 27 additions and 9 deletions

View File

@ -83,7 +83,8 @@ int64_t CalculateModifierKeyState(const std::vector<OHOS::Ace::KeyCode>& status)
return static_cast<int64_t>(modifierKeysState);
}
void SetDragEventProperty(const RefPtr<OHOS::Ace::DragEvent>& info, ArkUINodeEvent& event)
void SetDragEventProperty(const RefPtr<OHOS::Ace::DragEvent>& info, ArkUINodeEvent& event,
std::vector<const char*>& strList, std::vector<std::string>& keepStr)
{
event.dragEvent.touchPointX = info->GetPreviewRect().GetOffset().GetX();
event.dragEvent.touchPointY = info->GetPreviewRect().GetOffset().GetY();
@ -106,8 +107,6 @@ void SetDragEventProperty(const RefPtr<OHOS::Ace::DragEvent>& info, ArkUINodeEve
int32_t index = 0;
int32_t maxLength = 0;
std::vector<const char*> strList;
std::vector<std::string> keepStr(summary.size());
for (auto it = summary.begin(); it != summary.end(); it++) {
int32_t keyLength = static_cast<int32_t>(it->first.length());
maxLength = std::max(maxLength, keyLength);
@ -131,8 +130,11 @@ void SetOnDragDrop(ArkUINodeHandle node, void* extraParam)
event.nodeId = nodeId;
event.extraParam = reinterpret_cast<intptr_t>(extraParam);
event.dragEvent.subKind = ON_DRAG_DROP;
auto summary = info->GetSummary();
std::vector<const char*> strList;
std::vector<std::string> keepStr(summary.size());
SetDragEventProperty(info, event);
SetDragEventProperty(info, event, strList, keepStr);
auto unifiedData = UdmfClient::GetInstance()->TransformUnifiedDataPtr(info->GetData());
@ -158,7 +160,11 @@ void SetOnDragStart(ArkUINodeHandle node, void* extraParam)
event.nodeId = nodeId;
event.extraParam = reinterpret_cast<intptr_t>(extraParam);
event.dragEvent.subKind = ON_DRAG_START;
SetDragEventProperty(info, event);
auto summary = info->GetSummary();
std::vector<const char*> strList;
std::vector<std::string> keepStr(summary.size());
SetDragEventProperty(info, event, strList, keepStr);
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
SendArkUIAsyncEvent(&event);
@ -185,7 +191,11 @@ void SetOnDragEnter(ArkUINodeHandle node, void* extraParam)
event.extraParam = reinterpret_cast<intptr_t>(extraParam);
event.dragEvent.subKind = ON_DRAG_ENTER;
SetDragEventProperty(info, event);
auto summary = info->GetSummary();
std::vector<const char*> strList;
std::vector<std::string> keepStr(summary.size());
SetDragEventProperty(info, event, strList, keepStr);
auto unifiedData = UdmfClient::GetInstance()->TransformUnifiedDataPtr(info->GetData());
event.dragEvent.unifiedData = unifiedData;
@ -210,7 +220,11 @@ void SetOnDragMove(ArkUINodeHandle node, void* extraParam)
event.nodeId = nodeId;
event.extraParam = reinterpret_cast<intptr_t>(extraParam);
event.dragEvent.subKind = ON_DRAG_MOVE;
SetDragEventProperty(info, event);
auto summary = info->GetSummary();
std::vector<const char*> strList;
std::vector<std::string> keepStr(summary.size());
SetDragEventProperty(info, event, strList, keepStr);
auto unifiedData = UdmfClient::GetInstance()->TransformUnifiedDataPtr(info->GetData());
event.dragEvent.unifiedData = unifiedData;
PipelineContext::SetCallBackNode(AceType::WeakClaim(frameNode));
@ -234,7 +248,11 @@ void SetOnDragLeave(ArkUINodeHandle node, void* extraParam)
event.extraParam = reinterpret_cast<intptr_t>(extraParam);
event.dragEvent.subKind = ON_DRAG_LEAVE;
SetDragEventProperty(info, event);
auto summary = info->GetSummary();
std::vector<const char*> strList;
std::vector<std::string> keepStr(summary.size());
SetDragEventProperty(info, event, strList, keepStr);
auto unifiedData = UdmfClient::GetInstance()->TransformUnifiedDataPtr(info->GetData());
event.dragEvent.unifiedData = unifiedData;

View File

@ -114,7 +114,7 @@ int32_t OH_ArkUI_DragEvent_GetDataTypes(
if (ret != 0) {
return ARKUI_ERROR_CODE_PARAM_INVALID;
}
eventTypeArray[i][strLeng] = '\0';
eventTypeArray[i][strLeng - 1] = '\0';
} else {
eventTypeArray[i][0] = '\0';
}