From b1c31256888ac73c1a62a2b77944852efab2bc0f Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Tue, 29 Oct 2019 22:23:05 +0100 Subject: [PATCH] Fixed small bug related to the mouse PPI keys --- shared/js/ui/modal/ModalKeySelect.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/shared/js/ui/modal/ModalKeySelect.ts b/shared/js/ui/modal/ModalKeySelect.ts index af6ecda2..51885a19 100644 --- a/shared/js/ui/modal/ModalKeySelect.ts +++ b/shared/js/ui/modal/ModalKeySelect.ts @@ -13,11 +13,15 @@ namespace Modals { const button_save = modal.htmlTag.find(".button-save"); const button_cancel = modal.htmlTag.find(".button-cancel"); + let current_key_age: number; + let last_key; let current_key; const listener = (event: ppt.KeyEvent) => { if(event.type === ppt.EventType.KEY_PRESS) { //console.log(tr("Key select got key press for %o"), event); + last_key = current_key; current_key = event; + current_key_age = Date.now(); container_key.text(ppt.key_description(event)); button_save.prop("disabled", false); @@ -26,6 +30,9 @@ namespace Modals { button_save.on('click', () => { + /* Because pressing the close button is also a mouse action */ + if(current_key_age + 100 > Date.now()) + current_key = last_key; callback(current_key); modal.close(); }).prop("disabled", true);