From caeccac5d6b30889ebaba334cbf07870e6155953 Mon Sep 17 00:00:00 2001 From: bensaine Date: Fri, 18 Feb 2022 01:15:42 -0500 Subject: [PATCH] add: open quit dialog on escape if no modal, no keyboard capture active, no escapable window active, open quit dialog --- nel/src/gui/widget_manager.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/nel/src/gui/widget_manager.cpp b/nel/src/gui/widget_manager.cpp index c052f4c18..61f1a1fbf 100644 --- a/nel/src/gui/widget_manager.cpp +++ b/nel/src/gui/widget_manager.cpp @@ -2304,16 +2304,16 @@ namespace NLGUI SModalWndInfo mwi = getModal(); if (mwi.ModalExitKeyPushed) disableModalWindow(); - } - } - // Manage "quit window" If the Key is ESCAPE, no captureKeyboard - if( eventDesc.getKeyEventType() == CEventDescriptorKey::keydown && eventDesc.getKey() == NLMISC::KeyESCAPE ) - { - // Get the last escapable active top window. NB: this is ergonomically better. + handled= true; + } + CInterfaceGroup *win= getLastEscapableTopWindow(); - if( win ) + if ( win ) { + // Manage "quit window" If the Key is ESCAPE, no captureKeyboard + // Get the last escapable active top window. NB: this is ergonomically better. + // If the window is a modal, must pop it. if( dynamic_cast(win) ) { @@ -2399,7 +2399,13 @@ namespace NLGUI } } - // General case: handle it in the Captured keyboard + if (eventDesc.getKeyEventType() == CEventDescriptorKey::keydown && eventDesc.getKey() == NLMISC::KeyESCAPE && !handled && !isKeyboardCaptured()) + { + CAHManager::getInstance()->runActionHandler("enter_modal", NULL, "group=ui:interface:quit_dialog"); + handled = true; + } + + // General case: handle it in the Captured keyboard if ( getCaptureKeyboard() != NULL && !handled) { bool result = getCaptureKeyboard()->handleEvent(evnt);