From 8abe1f04bbb21b3d3788355947fe4e19f3b5a1aa Mon Sep 17 00:00:00 2001 From: Nicola <47360416+unsettledgames@users.noreply.github.com> Date: Sun, 12 Dec 2021 23:08:13 +0100 Subject: [PATCH] Binded closeDialogue to esc In that way the user can exit a dialogue without using the button and the mouse --- js/Dialogue.js | 2 ++ js/Input.js | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/js/Dialogue.js b/js/Dialogue.js index 26fcc8d..7ace4b8 100644 --- a/js/Dialogue.js +++ b/js/Dialogue.js @@ -8,6 +8,8 @@ const Dialogue = (() => { const popUpContainer = document.getElementById("pop-up-container"); const cancelButtons = popUpContainer.getElementsByClassName('close-button'); + Events.onCustom("esc-pressed", closeDialogue); + // Add click handlers for all cancel buttons for (var i = 0; i < cancelButtons.length; i++) { cancelButtons[i].addEventListener('click', function () { diff --git a/js/Input.js b/js/Input.js index df7cbf1..55395b9 100644 --- a/js/Input.js +++ b/js/Input.js @@ -75,13 +75,12 @@ const Input = (() => { } //if no document has been created yet or there is a dialog box open ignore hotkeys - if (!EditorState.documentCreated() || Dialogue.isOpen()) return; + if (!EditorState.documentCreated()) return; if (e.key === "Escape") { - console.log("esc"); Events.emit("esc-pressed"); } - else { + else if (!Dialogue.isOpen()){ switch (keyboardEvent.keyCode) { //pencil tool - 1, b case 49: case 66: