diff --git a/main.js b/main.js index f944ea8..6f6d461 100644 --- a/main.js +++ b/main.js @@ -1738,8 +1738,7 @@ function ShowMenu() { if (document.getElementById("HelperMenu") == null) { ShowMenuList(); } else { - document.getElementById("HelperMenu").parentNode.removeChild(document.getElementById( - "HelperMenu")); + CloseMenu(); } }); // adding click @@ -1836,7 +1835,7 @@ function ShowMenuList() { } 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.overflow = "auto"; @@ -1960,8 +1959,7 @@ function ShowMenuList() { xButton.style.top = menuDiv.offsetHeight + 'px'; xButton.addEventListener("click", function() { - document.getElementById("HelperMenu").parentNode.removeChild(document.getElementById( - "HelperMenu")); + CloseMenu(); }); // adding clicktextNode // help button ---------------------------------------------------------------------------------------------------------------- var helpButton = CreateNodeWithText(buttonCell, "Help", "button"); @@ -1998,6 +1996,20 @@ function ShowMenuList() { } catch (e) { 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); } //: }}}