1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-02-04 04:00:07 +00:00

MultiSelect: Added ImGuiMultiSelectFlags_ClearOnClickWindowVoid. + Demo: showcase multiple selection scopes in same window.

This commit is contained in:
ocornut 2023-04-11 19:40:02 +02:00
parent b91ae122e1
commit 35bbadcf0c
4 changed files with 54 additions and 21 deletions

View file

@ -7188,6 +7188,17 @@ ImGuiMultiSelectData* ImGui::EndMultiSelect()
ImGuiMultiSelectState* ms = &g.MultiSelectState;
IM_ASSERT(g.MultiSelectState.FocusScopeId == g.CurrentFocusScopeId);
// Clear selection when clicking void?
// We specifically test for IsMouseDragPastThreshold(0) == false to allow box-selection!
if (g.MultiSelectFlags & ImGuiMultiSelectFlags_ClearOnClickWindowVoid)
if (IsWindowHovered() && g.HoveredId == 0)
if (IsMouseReleased(0) && IsMouseDragPastThreshold(0) == false && g.IO.KeyMods == ImGuiMod_None)
{
ms->Out.RequestClear = true;
ms->Out.RequestSelectAll = ms->Out.RequestSetRange = false;
}
// Unwind
if (g.MultiSelectFlags & ImGuiMultiSelectFlags_NoUnselect)
ms->Out.RangeValue = true;
g.MultiSelectState.FocusScopeId = 0;