diff --git a/src/layouts/default/ItemContextMenu.vue b/src/layouts/default/ItemContextMenu.vue index b3c7e1c9..df733839 100644 --- a/src/layouts/default/ItemContextMenu.vue +++ b/src/layouts/default/ItemContextMenu.vue @@ -27,7 +27,35 @@ :disabled="menuItem.disabled == true" :prepend-icon="menuItem.icon" :append-icon="menuItem.selected ? 'mdi-check' : undefined" - @click="() => (menuItem.action ? menuItem.action() : '')" + @click.stop="(e) => menuItemClicked(e, menuItem)" + /> + + + + + + + + @@ -46,6 +74,11 @@ const items = ref([]); const posX = ref(0); const posY = ref(0); +const showSubmenu = ref(false); +const subMenuItems = ref([]); +const subMenuPosX = ref(0); +const subMenuPosY = ref(0); + onMounted(() => { eventbus.on('contextmenu', async (evt: ItemContextMenuDialogEvent) => { items.value = evt.items; @@ -59,6 +92,24 @@ onMounted(() => { eventbus.off('contextmenu'); }); }); + +const menuItemClicked = function ( + evt: MouseEvent | KeyboardEvent, + menuItem: ContextMenuItem, +) { + if (menuItem.subItems) { + evt.preventDefault(); + subMenuItems.value = menuItem.subItems; + (subMenuPosX.value = (evt as PointerEvent).clientX), + (subMenuPosY.value = (evt as PointerEvent).clientY), + (showSubmenu.value = true); + return; + } else if (menuItem.action) { + menuItem.action(); + } + show.value = false; + store.dialogActive = false; +};