Merge pull request #207 from one-some/UI2

Fix context menu (maybe)
This commit is contained in:
ebolam
2022-10-13 07:48:41 -04:00
committed by GitHub
2 changed files with 4 additions and 9 deletions

View File

@@ -1179,7 +1179,6 @@ body {
/* ---------------------------------- GAME SCREEN ----------------------------------*/ /* ---------------------------------- GAME SCREEN ----------------------------------*/
.gamescreen { .gamescreen {
background-color: var(--gamescreen_background); background-color: var(--gamescreen_background);
z-index: -1;
box-shadow: var(--light_shadow_value); box-shadow: var(--light_shadow_value);
color: var(--gamescreen_text); color: var(--gamescreen_text);
width: 100%; width: 100%;

View File

@@ -4703,7 +4703,7 @@ process_cookies();
item.addEventListener("click", action.click); item.addEventListener("click", action.click);
} }
$("#gamescreen").contextmenu(function(event) { $el("#gamescreen").addEventListener("contextmenu", function(event) {
// If control is held, do not run our custom logic or cancel the browser's. // If control is held, do not run our custom logic or cancel the browser's.
if (event.ctrlKey) return; if (event.ctrlKey) return;
@@ -4712,7 +4712,6 @@ process_cookies();
// Close if open // Close if open
if (!contextMenu.classList.contains("hidden")) { if (!contextMenu.classList.contains("hidden")) {
console.log("Close if open");
contextMenu.classList.add("hidden"); contextMenu.classList.add("hidden");
return; return;
} }
@@ -4729,26 +4728,23 @@ process_cookies();
contextMenu.classList.remove("hidden"); contextMenu.classList.remove("hidden");
// Set position to click position // Set position to click position
position_context_menu(contextMenu, event.originalEvent.x, event.originalEvent.y); position_context_menu(contextMenu, event.x, event.y);
// Don't let the document contextmenu catch us and close our context menu // Don't let the document contextmenu catch us and close our context menu
event.stopPropagation(); event.stopPropagation();
}); });
// When we make a browser context menu, close ours. // When we make a browser context menu, close ours.
$(document).contextmenu(function(event) { document.addEventListener("contextmenu", function(event) {
console.log("When we make a browser context menu, close ours.");
contextMenu.classList.add("hidden"); contextMenu.classList.add("hidden");
}); });
// When we click outside of our context menu, close ours. // When we click outside of our context menu, close ours.
$(document).click(function(event) { document.addEventListener("click", function(event) {
console.log("When we click outside of our context menu, close ours.");
contextMenu.classList.add("hidden"); contextMenu.classList.add("hidden");
}); });
window.addEventListener("blur", function(event) { window.addEventListener("blur", function(event) {
console.log("When we blur out of our context menu, close.");
contextMenu.classList.add("hidden"); contextMenu.classList.add("hidden");
}); });
})(); })();