mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 07:01:24 +00:00
Add new interface GetDropOperation
Signed-off-by: Zhang Jinyu <zhangjinyu101@huawei.com>
This commit is contained in:
parent
70addc0373
commit
180a52f533
@ -221,17 +221,30 @@ ArkUI_PreviewDragStatus OH_ArkUI_NodeEvent_GetPreviewDragStatus(ArkUI_NodeEvent*
|
||||
int32_t OH_ArkUI_DragEvent_DisableDefaultDropAnimation(ArkUI_DragEvent* event, bool disable);
|
||||
|
||||
/**
|
||||
* @brief Sets the data processing mode.
|
||||
* @brief Obtains the drop operation from a drag event.
|
||||
*
|
||||
* @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
|
||||
* @param dropOperation Indicates the data processing mode.
|
||||
* @param operation Indicates the drop operation which the data receiver set.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* Possible causes: 1. The given parameters are null or the given event is not a valid DragEvent.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragEvent_SetSuggestedDropOperation(ArkUI_DragEvent* event, ArkUI_DropOperation dropOperation);
|
||||
|
||||
/**
|
||||
* @brief Obtains the drop operation from a drag event.
|
||||
*
|
||||
* @param event Indicates the pointer to an <b>ArkUI_DragEvent</b> object.
|
||||
* @param operation Indicates the drop operation which the data receiver set.
|
||||
* @return Returns the result code.
|
||||
* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operations successful.
|
||||
* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs.
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_DragEvent_GetDropOperation(ArkUI_DragEvent* event, ArkUI_DropOperation* operation);
|
||||
|
||||
/**
|
||||
* @brief Sets the result for a drag event.
|
||||
*
|
||||
|
@ -562,6 +562,21 @@ int32_t OH_ArkUI_DragEvent_SetSuggestedDropOperation(ArkUI_DragEvent* event, Ark
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_DragEvent_GetDropOperation(ArkUI_DragEvent* event, ArkUI_DropOperation* operation)
|
||||
{
|
||||
if (!event || !operation) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
auto* dragEvent = reinterpret_cast<ArkUIDragEvent*>(event);
|
||||
if (dragEvent->dragBehavior >= static_cast<int32_t>(ArkUI_DropOperation::ARKUI_DROP_OPERATION_COPY) &&
|
||||
dragEvent->dragBehavior <= static_cast<int32_t>(ArkUI_DropOperation::ARKUI_DROP_OPERATION_MOVE)) {
|
||||
*operation = static_cast<ArkUI_DropOperation>(dragEvent->dragBehavior);
|
||||
} else {
|
||||
*operation = ARKUI_DROP_OPERATION_COPY;
|
||||
}
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
float OH_ArkUI_DragEvent_GetPreviewTouchPointX(ArkUI_DragEvent* event)
|
||||
{
|
||||
if (!event) {
|
||||
|
@ -1779,6 +1779,10 @@
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragEvent_SetSuggestedDropOperation"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragEvent_GetDropOperation"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DragEvent_SetDragResult"
|
||||
|
@ -627,4 +627,29 @@ HWTEST_F(DragAndDropTest, DragAndDropTest020, TestSize.Level1)
|
||||
ret = OHOS::Ace::NodeModel::ConvertToNodeEventType(ON_DRAG_END);
|
||||
EXPECT_EQ(ret, static_cast<int32_t>(NODE_ON_DRAG_END));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DragAndDropTest0021
|
||||
* @tc.desc: test OH_ArkUI_DragEvent_GetDropOperation.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DragAndDropTest, DragAndDropTest021, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
*@tc.steps : step1.create and set property.
|
||||
*/
|
||||
ArkUIDragEvent dragEvent;
|
||||
dragEvent.dragBehavior = ArkUI_DropOperation::ARKUI_DROP_OPERATION_MOVE;
|
||||
auto* drag_Event = reinterpret_cast<ArkUI_DragEvent*>(&dragEvent);
|
||||
ArkUI_DropOperation operation;
|
||||
auto ret = OH_ArkUI_DragEvent_GetDropOperation(drag_Event, &operation);
|
||||
|
||||
/**
|
||||
* @tc.expected: Return expected results.
|
||||
*/
|
||||
EXPECT_EQ(ret, ARKUI_ERROR_CODE_NO_ERROR);
|
||||
EXPECT_EQ(operation, ArkUI_DropOperation::ARKUI_DROP_OPERATION_MOVE);
|
||||
EXPECT_EQ(OH_ArkUI_DragEvent_GetDropOperation(nullptr, &operation), ARKUI_ERROR_CODE_PARAM_INVALID);
|
||||
EXPECT_EQ(OH_ArkUI_DragEvent_GetDropOperation(drag_Event, nullptr), ARKUI_ERROR_CODE_PARAM_INVALID);
|
||||
}
|
||||
} // namespace OHOS::Ace
|
Loading…
Reference in New Issue
Block a user