diff --git a/imgui_demo.cpp b/imgui_demo.cpp index 698e13a79..b4a7f099e 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -2901,7 +2901,8 @@ static void ShowDemoWindowMultiSelect() ImGui::SetNextItemSelectionUserData(n); if (widget_type == WidgetType_Selectable) { - if (ImGui::Selectable(label, item_is_selected)) + ImGui::Selectable(label, item_is_selected); + if (ImGui::IsItemToggledSelection()) selection.SetSelected(n, !item_is_selected); } else if (widget_type == WidgetType_TreeNode) diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 95224cac4..ba59b802c 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -6904,8 +6904,9 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl if (disabled_item && !disabled_global) EndDisabled(); + // Users of BeginMultiSelect() scope: call ImGui::IsItemToggledSelection() to retrieve selection toggle. Selectable() returns a pressed state! IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags); - return pressed || (was_selected != selected); //-V1020 + return pressed; //-V1020 } bool ImGui::Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags, const ImVec2& size_arg) @@ -7144,6 +7145,7 @@ ImGuiMultiSelectData* ImGui::BeginMultiSelect(ImGuiMultiSelectFlags flags, void* } // Auto clear when using Navigation to move within the selection (we compare SelectScopeId so it possible to use multiple lists inside a same window) + // FIXME: Polling key mods after the fact (frame following the move request) is incorrect, but latching it would requires non-trivial change in MultiSelectItemFooter() if (g.NavJustMovedToId != 0 && g.NavJustMovedToFocusScopeId == ms->FocusScopeId && g.NavJustMovedToHasSelectionData) { if (g.IO.KeyShift)