From 046fad01f1185d34c203d4f58f5adc0b7d28eaa9 Mon Sep 17 00:00:00 2001 From: omar Date: Sun, 29 Dec 2019 17:12:09 +0100 Subject: [PATCH] Tables: Return false when window is Collapsed (consistent + helpful for doc) + Fix empty context menu. --- imgui_tables.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/imgui_tables.cpp b/imgui_tables.cpp index 79ec8ef7..2ea3a96b 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -155,6 +155,8 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG { ImGuiContext& g = *GImGui; ImGuiWindow* outer_window = GetCurrentWindow(); + if (outer_window->SkipItems) // Consistent with other tables + beneficial side effect that assert on miscalling EndTable() will be more visible. + return false; // Sanity checks IM_ASSERT(columns_count > 0 && columns_count < IMGUI_TABLE_MAX_COLUMNS && "Only 0..63 columns allowed!"); @@ -1839,12 +1841,13 @@ void ImGui::TableAutoHeaders() // Context Menu if (open_context_popup != INT_MAX) - { - table->IsContextPopupOpen = true; - table->ContextPopupColumn = (ImS8)open_context_popup; - table->InstanceInteracted = table->InstanceNo; - OpenPopup("##TableContextMenu"); - } + if (table->Flags & (ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable)) + { + table->IsContextPopupOpen = true; + table->ContextPopupColumn = (ImS8)open_context_popup; + table->InstanceInteracted = table->InstanceNo; + OpenPopup("##TableContextMenu"); + } } // Emit a column header (text + optional sort order)