From f8bc2f0d22166e89a74a145689e513bbfcf32718 Mon Sep 17 00:00:00 2001 From: Ozbolt Menegatti Date: Tue, 14 Jan 2020 21:57:36 +0100 Subject: [PATCH] enter works now when modal is up. --- src/message/simple_messages.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/message/simple_messages.py b/src/message/simple_messages.py index c9ec7ac..9977d1b 100644 --- a/src/message/simple_messages.py +++ b/src/message/simple_messages.py @@ -1,4 +1,4 @@ -from browser import window +from browser import window, document from message.message import Message, msg @@ -37,7 +37,14 @@ class KeyboardPress(Message): return key == "Escape" def update_model(self, model): - pass + key = self.get_arg(0, str) + + # Enter when modal shown -> press ok button + if model.modal_shown and key == "Enter": + ok_button = document.getElementById("modal-ok") + if ok_button is not None: + # has to be called in separate thread + window.setTimeout(lambda: ok_button.click(), 10) # a "hack" message for reseting modals #