diff --git a/app.vue b/app.vue
index 8f0571f..391fc96 100644
--- a/app.vue
+++ b/app.vue
@@ -1,7 +1,7 @@
-
+
@@ -12,22 +12,29 @@ import type { ContextMenuInterface } from './types/interfaces';
const banner = useState("banner", () => false);
-const contextMenu = useState("contextMenu");
+const contextMenu = useState("contextMenu", () => ({ show: false, pointerX: 0, pointerY: 0, sections: [] }));
onMounted(() => {
loadPreferredThemes()
- document.removeEventListener("contextmenu", contextMenuHandler);
document.addEventListener("contextmenu", (e) => {
- if (e.target instanceof Element && e.target.classList.contains("default-contextmenu")) return;
- contextMenuHandler(e);
+ if (contextMenu.value.show) {
+ e.preventDefault();
+ if (e.target instanceof Element && !e.target.classList.contains("context-menu-item")) {
+ removeContextMenu(contextMenu);
+ }
+ }
});
+
document.addEventListener("mousedown", (e) => {
- if (e.target instanceof HTMLElement && e.target.closest("#context-menu")) return;
+ if (e.target instanceof HTMLElement && e.target.classList.contains("context-menu-item")) return;
console.log("click");
console.log("target:", e.target);
console.log(e.target instanceof HTMLDivElement);
- removeContextMenu(contextMenu);
+ if (e.button != 2 && contextMenu.value.show) {
+ console.log("context menu is shown, hiding");
+ removeContextMenu(contextMenu);
+ }
if (e.target instanceof HTMLElement && e.target.classList.contains("message-text") && e.target.contentEditable) {
e.target.contentEditable = "false";
}
@@ -52,14 +59,6 @@ onMounted(() => {
});
});
-function contextMenuHandler(e: MouseEvent) {
- e.preventDefault();
- //console.log("Opened context menu");
- //createContextMenu(e, [
- // { name: "Wah", callback: () => { return } }
- //]);
-}
-
\ No newline at end of file
diff --git a/components/UserInterface/ContextMenu.vue b/components/UserInterface/ContextMenu.vue
index 1767657..2392097 100644
--- a/components/UserInterface/ContextMenu.vue
+++ b/components/UserInterface/ContextMenu.vue
@@ -1,23 +1,33 @@