From 57551c791dd133e96aba690a8217e2f4c218fce4 Mon Sep 17 00:00:00 2001 From: friarzen Date: Tue, 27 Nov 2018 03:54:52 +0000 Subject: [PATCH] Modal dialogs should capture all keystrokes but not interfere with other onKeydowns --- .../webclient/js/plugins/splithandler.js | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/evennia/web/webclient/static/webclient/js/plugins/splithandler.js b/evennia/web/webclient/static/webclient/js/plugins/splithandler.js index ec08b862a3..c32cf32c1b 100644 --- a/evennia/web/webclient/static/webclient/js/plugins/splithandler.js +++ b/evennia/web/webclient/static/webclient/js/plugins/splithandler.js @@ -365,6 +365,30 @@ let splithandler_plugin = (function () { return false; } + // + // onKeydown check for 'ESC' key. + var onKeydown = function (event) { + var code = event.which; + + if (code === 27) { // Escape key + if ($('#splitdialogcontent').is(':visible')) { + plugins['popups'].closePopup("#splitdialogcontent"); + return true; + } + if ($('#panedialogcontent').is(':visible')) { + plugins['popups'].closePopup("#panedialogcontent"); + return true; + } + } + + // capture all keys while one of our "modal" dialogs is open + if ($('#splitdialogcontent').is(':visible') || $('#panedialogcontent').is(':visible')) { + return true; + } + + return false; + } + // // Required plugin "init" function var init = function(settings) { @@ -408,6 +432,7 @@ let splithandler_plugin = (function () { dynamic_split: dynamic_split, undo_split: undo_split, set_pane_types: set_pane_types, + onKeydown: onKeydown, } })() plugin_handler.add('splithandler', splithandler_plugin);