mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
RangeSelect/MultiSelect: Fix Selectable() ambiguous return value, clarify need to use IsItemToggledSelection().
This commit is contained in:
parent
f68e03d92e
commit
910d83951d
@ -1316,7 +1316,8 @@ static void ShowDemoWindowWidgets()
|
|||||||
ImGui::SetNextItemSelectionData((void*)(intptr_t)n);
|
ImGui::SetNextItemSelectionData((void*)(intptr_t)n);
|
||||||
if (widget_type == WidgetType_Selectable)
|
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);
|
selection.SetSelected(n, !item_is_selected);
|
||||||
}
|
}
|
||||||
else if (widget_type == WidgetType_TreeNode)
|
else if (widget_type == WidgetType_TreeNode)
|
||||||
|
@ -6342,8 +6342,9 @@ bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags fl
|
|||||||
if (disabled_item && !disabled_global)
|
if (disabled_item && !disabled_global)
|
||||||
EndDisabled();
|
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);
|
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)
|
bool ImGui::Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags, const ImVec2& size_arg)
|
||||||
@ -6393,6 +6394,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)
|
// 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 == state->FocusScopeId && g.NavJustMovedToHasSelectionData)
|
if (g.NavJustMovedToId != 0 && g.NavJustMovedToFocusScopeId == state->FocusScopeId && g.NavJustMovedToHasSelectionData)
|
||||||
{
|
{
|
||||||
if (g.IO.KeyShift)
|
if (g.IO.KeyShift)
|
||||||
|
Loading…
Reference in New Issue
Block a user