Fixed ugly scrollbar on menu, and now closes on ESC

This commit is contained in:
YourFriendlyNeighborhoodDealer 2019-03-04 08:19:47 +01:00
parent 775e973681
commit 31951a5cb9

22
main.js
View file

@ -1738,8 +1738,7 @@ function ShowMenu() {
if (document.getElementById("HelperMenu") == null) { if (document.getElementById("HelperMenu") == null) {
ShowMenuList(); ShowMenuList();
} else { } else {
document.getElementById("HelperMenu").parentNode.removeChild(document.getElementById( CloseMenu();
"HelperMenu"));
} }
}); // adding click }); // adding click
@ -1836,7 +1835,7 @@ function ShowMenuList() {
} }
var scrollDiv = document.createElement("div"); var scrollDiv = document.createElement("div");
scrollDiv.style.width = window.innerWidth / 2 + 'px'; scrollDiv.style.width = '100%';
scrollDiv.style.height = window.innerHeight - (window.innerHeight * 0.4) + "px"; scrollDiv.style.height = window.innerHeight - (window.innerHeight * 0.4) + "px";
scrollDiv.style.overflow = "auto"; scrollDiv.style.overflow = "auto";
@ -1960,8 +1959,7 @@ function ShowMenuList() {
xButton.style.top = menuDiv.offsetHeight + 'px'; xButton.style.top = menuDiv.offsetHeight + 'px';
xButton.addEventListener("click", function() { xButton.addEventListener("click", function() {
document.getElementById("HelperMenu").parentNode.removeChild(document.getElementById( CloseMenu();
"HelperMenu"));
}); // adding clicktextNode }); // adding clicktextNode
// help button ---------------------------------------------------------------------------------------------------------------- // help button ----------------------------------------------------------------------------------------------------------------
var helpButton = CreateNodeWithText(buttonCell, "Help", "button"); var helpButton = CreateNodeWithText(buttonCell, "Help", "button");
@ -1998,6 +1996,20 @@ function ShowMenuList() {
} catch (e) { } catch (e) {
Exception(e, "script error at showing menu list:"); Exception(e, "script error at showing menu list:");
} }
document.addEventListener("keydown", EscClose);
}
function EscClose(e) {
if (e.keyCode == 27)
CloseMenu();
}
function CloseMenu() {
document.getElementById("HelperMenu").parentNode.removeChild(document.getElementById(
"HelperMenu"));
document.removeEventListener("keydown", EscClose);
} }
//: }}} //: }}}