add 多选拖拽Sample 增加menu菜单

Signed-off-by: b30058220 <baodi1@huawei.com>
This commit is contained in:
b30058220 2024-07-02 17:00:47 +08:00
parent df9ce15ef0
commit 75be276aea
4 changed files with 16 additions and 3 deletions

View File

@ -36,6 +36,17 @@ export struct MultiSelectDrag {
@State previewData: DragItemInfo[] = [{}, {}, {}, {}, {}, {}, {}, {}, {}];
@State pixmap: image.PixelMap | undefined = undefined;
@Builder
MenuBuilder() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Button('Test ContextMenu1')
Divider().strokeWidth(2).margin(5).color(Color.Black)
Button('Test ContextMenu2')
Divider().strokeWidth(2).margin(5).color(Color.Black)
Button('Test ContextMenu3')
}
}
@Builder
createGrid() {
Grid() {
@ -68,6 +79,7 @@ export struct MultiSelectDrag {
.dragPreviewOptions({
mode: [DragPreviewMode.ENABLE_DEFAULT_SHADOW, DragPreviewMode.ENABLE_DEFAULT_RADIUS]
}, { isMultiSelectionEnabled: true, defaultAnimationBeforeLifting: true })
.bindContextMenu(this.MenuBuilder, ResponseType.LongPress, { preview: MenuPreviewMode.NONE })
.dragPreview(`gridItemId${index}`)
.onDragStart(() => {

View File

@ -3538,7 +3538,8 @@ export default function abilityTest() {
await checkButtonAndClickWithID('gridItemId1');
await checkButtonAndClickWithID('gridItemId3');
await checkButtonAndClickWithID('gridItemId4');
await checkButtonAndDragToTargetWithID('gridItemId0', column);
let gridItemId8 = await driver.findComponent(ON.id('gridItemId8'));
await checkButtonAndDragToTargetWithID('gridItemId0', gridItemId8);
// 滑动slider调整 固定坐标只支持RK3568其他设备需要调整
await driver.drag(660, 600, 660, 0);