Tables, Multi-Select: Fixed an issue using Multi-Select within a Table causing column width measurement to be invalid when trailing column contents is not submitted in the last row. (#9341, #8250)

This commit is contained in:
ocornut
2026-04-16 15:07:56 +02:00
parent 39e7bf5a08
commit ce855cada2
2 changed files with 8 additions and 2 deletions

View File

@@ -59,6 +59,8 @@ Other Changes:
- Child windows with only ImGuiChildFlags_AutoResizeY flag keep using the proportional
default ItemWidth. (#9355)
- Multi-Select:
- Fixed an issue using Multi-Select within a Table causing column width measurement to
be invalid when trailing column contents is not submitted in the last row. (#9341, #8250)
- Box-Select: fixed an issue using ImGuiMultiSelectFlags_BoxSelect2d mode, where
items out of view wouldn't be properly selected while scrolling while mouse cursor
is hovering outside of selection scope. (#7994, #1861, #6518)

View File

@@ -7917,6 +7917,7 @@ static ImRect CalcScopeRect(ImGuiMultiSelectTempData* ms, ImGuiWindow* window)
if (ms->Flags & ImGuiMultiSelectFlags_ScopeRect)
{
// Warning: this depends on CursorMaxPos so it means to be called by EndMultiSelect() only
// This probably doesn't work inside a table as there are ample ambiguities related to exact time of calling BeginMultiSelect()/EndMultiSelect().
return ImRect(ms->ScopeRectMin, ImMax(window->DC.CursorMaxPos, ms->ScopeRectMin));
}
else
@@ -7974,7 +7975,7 @@ ImGuiMultiSelectIO* ImGui::BeginMultiSelect(ImGuiMultiSelectFlags flags, int sel
ms->Flags = flags;
ms->IsFocused = (ms->FocusScopeId == g.NavFocusScopeId);
ms->BackupCursorMaxPos = window->DC.CursorMaxPos;
ms->ScopeRectMin = window->DC.CursorMaxPos = window->DC.CursorPos;
ms->ScopeRectMin = window->DC.CursorMaxPos = window->DC.CursorPos; // CalcScopeRect() for ImGuiMultiSelectFlags_ScopeRect will measure in EndMultiSelect().
PushFocusScope(ms->FocusScopeId);
if (flags & ImGuiMultiSelectFlags_ScopeWindow) // Mark parent child window as navigable into, with highlight. Assume user will always submit interactive items.
window->DC.NavLayersActiveMask |= 1 << ImGuiNavLayer_Main;
@@ -8129,10 +8130,13 @@ ImGuiMultiSelectIO* ImGui::EndMultiSelect()
if (ms->Flags & ImGuiMultiSelectFlags_NavWrapX)
{
IM_ASSERT(ms->Flags & ImGuiMultiSelectFlags_ScopeWindow); // Only supported at window scope
ImGui::NavMoveRequestTryWrapping(ImGui::GetCurrentWindow(), ImGuiNavMoveFlags_WrapX);
NavMoveRequestTryWrapping(GetCurrentWindow(), ImGuiNavMoveFlags_WrapX);
}
// Unwind
if (ImGuiTable* table = g.CurrentTable)
if (table->IsInsideRow)
TableEndRow(table);
window->DC.CursorMaxPos = ImMax(ms->BackupCursorMaxPos, window->DC.CursorMaxPos);
PopFocusScope();