From bbd0af72565c12322ce4b3864d030991dc0e698f Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 9 Apr 2026 19:38:15 +0200 Subject: [PATCH] Multi-Select: Box-Select+Tables: fixed using BeginMultiSelect() before table layout is locked. (#8250) --- docs/CHANGELOG.txt | 2 ++ imgui_tables.cpp | 2 +- imgui_widgets.cpp | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index e18f5a996..ab05e516a 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -72,6 +72,8 @@ Other Changes: and ImGuiSelectionUserData is technically opaque storage. (#7994, #1861) (we will probably bring this back as a minor optimization if we have a way to for user to tell us ImGuiSelectionUserData are indices) + - Box-Select, Tables: fixed an issue when calling `BeginMultiSelect()` in a table + before layout has been locked (first row or headers row submitted). (#8250) - Fonts: - imgui_freetype: add FreeType headers & compiled version in 'About Dear ImGui' details. - Clipper: diff --git a/imgui_tables.cpp b/imgui_tables.cpp index d06fe1e7b..c311c9040 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -1647,7 +1647,7 @@ void ImGui::TableSetupColumn(const char* label, ImGuiTableColumnFlags flags, flo ImGuiTable* table = g.CurrentTable; IM_ASSERT_USER_ERROR_RET(table != NULL, "Call should only be done while in BeginTable() scope!"); IM_ASSERT_USER_ERROR_RET(table->DeclColumnsCount < table->ColumnsCount, "TableSetupColumn(): called too many times!"); - IM_ASSERT_USER_ERROR_RET(table->IsLayoutLocked == false, "TableSetupColumn(): need to call before first row!"); + IM_ASSERT_USER_ERROR_RET(table->IsLayoutLocked == false, "TableSetupColumn(): need to call before first row!"); // Table layout is locked when submitting a row or when calling BeginMultiSelect() with box-select. IM_ASSERT((flags & ImGuiTableColumnFlags_StatusMask_) == 0 && "Illegal to pass StatusMask values to TableSetupColumn()"); ImGuiTableColumn* column = &table->Columns[table->DeclColumnsCount]; diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index e94dd3e87..0d1a178c5 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -7958,8 +7958,12 @@ ImGuiMultiSelectIO* ImGui::BeginMultiSelect(ImGuiMultiSelectFlags flags, int sel // FIXME: Workaround to the fact we override CursorMaxPos, meaning size measurement are lost. (#8250) // They should perhaps be stacked properly? if (ImGuiTable* table = g.CurrentTable) - if (table->CurrentColumn != -1) + { + if (!table->IsLayoutLocked) + TableUpdateLayout(table); + else if (table->CurrentColumn != -1) TableEndCell(table); // This is currently safe to call multiple time. If that properly is lost we can extract the "save measurement" part of it. + } // FIXME: BeginFocusScope() const ImGuiID id = window->IDStack.back();