From b493cae8c971843886d760bb816dcab661779d69 Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 23 Apr 2021 19:08:22 +0200 Subject: [PATCH] Nav: Fixed pressing Escape to leave menu layer while in a popup or child window. (#787) --- docs/CHANGELOG.txt | 5 +++-- imgui.cpp | 10 +++++----- imgui.h | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 3e2d6098d..8679fe12a 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -43,9 +43,10 @@ Other Changes: - Scrolling: Fix scroll snapping on edge of scroll region when both scrollbars are enabled. - Scrolling: Fix mouse wheel axis swap when using SHIFT on macOS (system already does it). (#4010) - Window: Fix IsWindowAppearing() from returning true twice in most cases. (#3982, #1497, #1061) -- Nav: Fixed using SetItemDefaultFocus() on windows with _NavFlattened flag. -- Nav: Fixed toggling menu layer while an InputText() is active not stealing active id. +- Nav: Fixed toggling menu layer while an InputText() is active not stealing active id. (#787) +- Nav: Fixed pressing Escape to leave menu layer while in a popup or child window. (#787) - Nav, InputText: Fixed accidental menu toggling while typing non-ascii characters using AltGR. [@rokups] (#370) +- Nav: Fixed using SetItemDefaultFocus() on windows with _NavFlattened flag. (#787) - Tables: Expose TableSetColumnEnabled() in public api. (#3935) - Tables: Better preserve widths when columns count changes. (#4046) - TabBar: Fixed mouse reordering with very fast movements (e.g. crossing multiple tabs in a single diff --git a/imgui.cpp b/imgui.cpp index cad4922bf..18364c78a 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -9114,6 +9114,11 @@ static void ImGui::NavUpdate() if (!IsActiveIdUsingNavInput(ImGuiNavInput_Cancel)) ClearActiveID(); } + else if (g.NavLayer != ImGuiNavLayer_Main) + { + // Leave the "menu" layer + NavRestoreLayer(ImGuiNavLayer_Main); + } else if (g.NavWindow && g.NavWindow != g.NavWindow->RootWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_Popup) && g.NavWindow->ParentWindow) { // Exit child window @@ -9130,11 +9135,6 @@ static void ImGui::NavUpdate() if (!(g.OpenPopupStack.back().Window->Flags & ImGuiWindowFlags_Modal)) ClosePopupToLevel(g.OpenPopupStack.Size - 1, true); } - else if (g.NavLayer != ImGuiNavLayer_Main) - { - // Leave the "menu" layer - NavRestoreLayer(ImGuiNavLayer_Main); - } else { // Clear NavLastId for popups but keep it for regular child window so we can leave one and come back where we were diff --git a/imgui.h b/imgui.h index ee36cfd65..a72ed3f7b 100644 --- a/imgui.h +++ b/imgui.h @@ -61,7 +61,7 @@ Index of this file: // Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens) #define IMGUI_VERSION "1.83 WIP" -#define IMGUI_VERSION_NUM 18205 +#define IMGUI_VERSION_NUM 18206 #define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx)) #define IMGUI_HAS_TABLE