Binded closeDialogue to esc

In that way the user can exit a dialogue without using the button and the mouse
This commit is contained in:
Nicola 2021-12-12 23:08:13 +01:00
parent 8433b6018a
commit 8abe1f04bb
2 changed files with 4 additions and 3 deletions

View File

@ -8,6 +8,8 @@ const Dialogue = (() => {
const popUpContainer = document.getElementById("pop-up-container"); const popUpContainer = document.getElementById("pop-up-container");
const cancelButtons = popUpContainer.getElementsByClassName('close-button'); const cancelButtons = popUpContainer.getElementsByClassName('close-button');
Events.onCustom("esc-pressed", closeDialogue);
// Add click handlers for all cancel buttons // Add click handlers for all cancel buttons
for (var i = 0; i < cancelButtons.length; i++) { for (var i = 0; i < cancelButtons.length; i++) {
cancelButtons[i].addEventListener('click', function () { cancelButtons[i].addEventListener('click', function () {

View File

@ -75,13 +75,12 @@ const Input = (() => {
} }
//if no document has been created yet or there is a dialog box open ignore hotkeys //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") { if (e.key === "Escape") {
console.log("esc");
Events.emit("esc-pressed"); Events.emit("esc-pressed");
} }
else { else if (!Dialogue.isOpen()){
switch (keyboardEvent.keyCode) { switch (keyboardEvent.keyCode) {
//pencil tool - 1, b //pencil tool - 1, b
case 49: case 66: case 49: case 66: