From ebbca15bde9ac92f99de930a626fa35234285436 Mon Sep 17 00:00:00 2001 From: ocornut Date: Sat, 20 May 2023 15:59:30 +0200 Subject: [PATCH] RangeSelect/MultiSelect: Enter can alter selection if current item is not selected. --- imgui_widgets.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 42cd46c2..aee6fd37 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -7184,11 +7184,13 @@ void ImGui::MultiSelectItemFooter(ImGuiID id, bool* p_selected, bool* p_pressed) } } - // Unlike Space, Enter doesn't alter selection (but can still return a press) + // Unlike Space, Enter doesn't alter selection (but can still return a press) unless current item is not selected. + // The later, "unless current item is not select", may become optional? It seems like a better default if Enter doesn't necessarily open something + // (unlike e.g. Windows explorer). For use case where Enter always open something, we might decide to make this optional? const bool enter_pressed = pressed && (g.NavActivateId == id) && (g.NavActivateFlags & ImGuiActivateFlags_PreferInput); // Alter selection - if (pressed && !enter_pressed) + if (pressed && (!enter_pressed || !selected)) { //------------------------------------------------------------------------------------------------------------------------------------------------- // ACTION | Begin | Item Old | Item New | End