!4563 多选拖拽Sample 增加menu菜单

Merge pull request !4563 from bd/multiselectdrag
This commit is contained in:
openharmony_ci 2024-07-03 08:36:27 +00:00 committed by Gitee
commit 463a16ea1a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
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);