From f103ea3daca3b678e4d65760d2072b211efa9bea Mon Sep 17 00:00:00 2001 From: cutealien Date: Wed, 26 May 2021 13:57:12 +0000 Subject: [PATCH] Bugfix: Changing focus with tab-keys now also work when elements are inside a modal screen. Event got eaten before. It passes it now on partly (enough to arrive at CGUIEnvironment) when the focus will stay inside the modal screen. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6215 dfc29bdd-3216-0410-991c-e03cc46cb475 --- changes.txt | 1 + source/Irrlicht/CGUIEnvironment.cpp | 2 +- source/Irrlicht/CGUIModalScreen.cpp | 13 +++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/changes.txt b/changes.txt index 60b88af0..7407b2d9 100644 --- a/changes.txt +++ b/changes.txt @@ -1,5 +1,6 @@ -------------------------- Changes in 1.9 (not yet released) +- Bugfix: Changing focus with tab-keys now also work when elements are inside a modal screen. - COBJMeshFileLoader using a bit more exact color conversion for 0-1 to 0-255 range (same now as SColorf::toSColor uses). - Speedup for COBJMeshWriter - Add blinkMode parameter to IGUIEnvironment::addModalScreen, so blinking can be suppressed diff --git a/source/Irrlicht/CGUIEnvironment.cpp b/source/Irrlicht/CGUIEnvironment.cpp index 465a20d4..5d2a5f02 100644 --- a/source/Irrlicht/CGUIEnvironment.cpp +++ b/source/Irrlicht/CGUIEnvironment.cpp @@ -642,8 +642,8 @@ bool CGUIEnvironment::postEventFromUser(const SEvent& event) // For keys we handle the event before changing focus to give elements the chance for catching the TAB // Send focus changing event + // CAREFUL when changing - there's an identical check in CGUIModalScreen::OnEvent if (FocusFlags & EFF_SET_ON_TAB && - event.EventType == EET_KEY_INPUT_EVENT && event.KeyInput.PressedDown && event.KeyInput.Key == KEY_TAB) { diff --git a/source/Irrlicht/CGUIModalScreen.cpp b/source/Irrlicht/CGUIModalScreen.cpp index 1555cc26..d18048cc 100644 --- a/source/Irrlicht/CGUIModalScreen.cpp +++ b/source/Irrlicht/CGUIModalScreen.cpp @@ -136,6 +136,19 @@ bool CGUIModalScreen::OnEvent(const SEvent& event) { MouseDownTime = os::Timer::getTime(); } + case EET_KEY_INPUT_EVENT: + // CAREFUL when changing - there's an identical check in CGUIEnvironment::postEventFromUser + if (Environment->getFocusBehavior() & EFF_SET_ON_TAB && + event.KeyInput.PressedDown && + event.KeyInput.Key == KEY_TAB) + { + IGUIElement* next = Environment->getNextElement(event.KeyInput.Shift, event.KeyInput.Control); + if ( next && isMyChild(next) ) + { + // Pass on the TAB-key, otherwise focus-tabbing inside modal screens breaks + return false; + } + } default: break; }