From a02315e1c4c80f94008779bfa0cc552542cb2f08 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 28 Jun 2023 15:47:10 +0200 Subject: [PATCH] Combo: Made simple/legacy Combo() function not returns true when picking already selected item. (#1182) --- docs/CHANGELOG.txt | 2 ++ docs/TODO.txt | 1 - imgui_widgets.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 1545cf8d..403935a6 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -88,6 +88,8 @@ Other changes: - CollapsingHeader/TreeNode: Fixed text padding when using _Framed+_Leaf flags. (#6549) [@BobbyAnguelov] - InputText: Fixed not returning true when buffer is cleared while using the ImGuiInputTextFlags_EscapeClearsAll flag. (#5688, #2620) +- Combo: Made simple/legacy Combo() function not returns true when picking already selected item. + This is consistent with other widgets. If you need something else, you can use BeginCombo(). (#1182) - Clipper: Rework inner logic to allow functioning with a zero-clear constructor. This is order to facilitate usage for language bindings (e.g cimgui or dear_binding) where user may not be callinga constructor manually. (#5856) diff --git a/docs/TODO.txt b/docs/TODO.txt index 28b715de..5fb82934 100644 --- a/docs/TODO.txt +++ b/docs/TODO.txt @@ -167,7 +167,6 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i - drag float: added leeway on edge (e.g. a few invisible steps past the clamp limits) - combo: use clipper. - - combo: flag for BeginCombo to not return true when unchanged (#1182) - combo: a way/helper to customize the combo preview (#1658) -> experimental BeginComboPreview() - combo/listbox: keyboard control. need InputText-like non-active focus + key handling. considering keyboard for custom listbox (pr #203) - listbox: multiple selection (WIP range-select branch) diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index ecdb2d61..67e5d3ac 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -1926,7 +1926,7 @@ bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(voi const char* item_text; if (!items_getter(data, i, &item_text)) item_text = "*Unknown item*"; - if (Selectable(item_text, item_selected)) + if (Selectable(item_text, item_selected) && *current_item != i) { value_changed = true; *current_item = i;