Skip to content

Commit ae6cfd3

Browse files
committed
Tables, Menus: Fixed tables or child windows submitted inside BeginMainMenuBar() being unable to save their settings. (ocornut#8356)
Amend error handling (fa178f4) to avoid us setting ImGuiWindowFlags_NoSavedSettings on the wrong window.
1 parent fa178f4 commit ae6cfd3

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

docs/CHANGELOG.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ Other changes:
7575
- Tables, Menus: Fixed using BeginTable() in menu layer (any menu bar). (#8355)
7676
It previously overrode the current layer back to main layer, which caused an issue
7777
with MainMenuBar attempted to release focus when leaving the menu layer.
78+
- Tables, Menus: Fixed tables or child windows submitted inside BeginMainMenuBar()
79+
being unable to save their settings, as the main menu bar uses _NoSavedSettings. (#8356)
7880
- ColorEdit, ColorPicker: Fixed alpha preview broken in 1.91.7. (#8336, #8241). [@PathogenDavid]
7981
- Tabs, Style: reworked selected overline rendering to better accommodate
8082
for rounded tabs. Reduced default thickness (style.TabBarOverlineSize),

imgui_widgets.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8755,18 +8755,29 @@ bool ImGui::BeginMainMenuBar()
87558755
float height = GetFrameHeight();
87568756
bool is_open = BeginViewportSideBar("##MainMenuBar", viewport, ImGuiDir_Up, height, window_flags);
87578757
g.NextWindowData.MenuBarOffsetMinVal = ImVec2(0.0f, 0.0f);
8758-
8759-
if (is_open)
8760-
BeginMenuBar();
8761-
else
8758+
if (!is_open)
8759+
{
87628760
End();
8761+
return false;
8762+
}
8763+
8764+
// Temporarily disable _NoSavedSettings, in the off-chance that tables or child windows submitted within the menu-bar may want to use settings. (#8356)
8765+
g.CurrentWindow->Flags &= ~ImGuiWindowFlags_NoSavedSettings;
8766+
BeginMenuBar();
87638767
return is_open;
87648768
}
87658769

87668770
void ImGui::EndMainMenuBar()
87678771
{
87688772
ImGuiContext& g = *GImGui;
8773+
if (!g.CurrentWindow->DC.MenuBarAppending)
8774+
{
8775+
IM_ASSERT_USER_ERROR(0, "Calling EndMainMenuBar() not from a menu-bar!"); // Not technically testing that it is the main menu bar
8776+
return;
8777+
}
8778+
87698779
EndMenuBar();
8780+
g.CurrentWindow->Flags |= ImGuiWindowFlags_NoSavedSettings; // Restore _NoSavedSettings (#8356)
87708781

87718782
// When the user has left the menu layer (typically: closed menus through activation of an item), we restore focus to the previous window
87728783
// FIXME: With this strategy we won't be able to restore a NULL focus.

0 commit comments

Comments
 (0)