MultiSelect: Fix Selectable() ambiguous return value, clarify need to use IsItemToggledSelection().
This commit is contained in:
parent
0479b188d0
commit
3ba3f0d905
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user