|
|
@@ -4146,6 +4146,9 @@ ImVec2 ImGui::GetMousePosOnOpeningCurrentPopup()
|
|
|
// We typically use ImVec2(-FLT_MAX,-FLT_MAX) to denote an invalid mouse position.
|
|
|
bool ImGui::IsMousePosValid(const ImVec2* mouse_pos)
|
|
|
{
|
|
|
+ // The assert is only to silence a false-positive in XCode Static Analysis.
|
|
|
+ // Because GImGui is not dereferenced in every code path, the static analyzer assume that it may be NULL (which it doesn't for other functions).
|
|
|
+ IM_ASSERT(GImGui != NULL);
|
|
|
const float MOUSE_INVALID = -256000.0f;
|
|
|
ImVec2 p = mouse_pos ? *mouse_pos : GImGui->IO.MousePos;
|
|
|
return p.x >= MOUSE_INVALID && p.y >= MOUSE_INVALID;
|
|
|
@@ -6836,8 +6839,21 @@ void ImGui::CloseCurrentPopup()
|
|
|
int popup_idx = g.BeginPopupStack.Size - 1;
|
|
|
if (popup_idx < 0 || popup_idx >= g.OpenPopupStack.Size || g.BeginPopupStack[popup_idx].PopupId != g.OpenPopupStack[popup_idx].PopupId)
|
|
|
return;
|
|
|
- while (popup_idx > 0 && g.OpenPopupStack[popup_idx].Window && (g.OpenPopupStack[popup_idx].Window->Flags & ImGuiWindowFlags_ChildMenu))
|
|
|
+
|
|
|
+ // Closing a menu closes its top-most parent popup (unless a modal)
|
|
|
+ while (popup_idx > 0)
|
|
|
+ {
|
|
|
+ ImGuiWindow* popup_window = g.OpenPopupStack[popup_idx].Window;
|
|
|
+ ImGuiWindow* parent_popup_window = g.OpenPopupStack[popup_idx - 1].Window;
|
|
|
+ bool close_parent = false;
|
|
|
+ if (popup_window && (popup_window->Flags & ImGuiWindowFlags_ChildMenu))
|
|
|
+ if (parent_popup_window == NULL || !(parent_popup_window->Flags & ImGuiWindowFlags_Modal))
|
|
|
+ close_parent = true;
|
|
|
+ if (!close_parent)
|
|
|
+ break;
|
|
|
popup_idx--;
|
|
|
+ }
|
|
|
+ //IMGUI_DEBUG_LOG("CloseCurrentPopup %d -> %d\n", g.BeginPopupStack.Size - 1, popup_idx);
|
|
|
ClosePopupToLevel(popup_idx, true);
|
|
|
|
|
|
// A common pattern is to close a popup when selecting a menu item/selectable that will open another window.
|