MultiSelect: BoxSelect: fixed box-select from void setting nav id multiple times.
This commit is contained in:
parent
237165a935
commit
ed356dc181
@ -1719,6 +1719,7 @@ struct ImGuiBoxSelectState
|
||||
bool IsActive;
|
||||
bool IsStarting;
|
||||
bool IsStartedFromVoid; // Starting click was not from an item.
|
||||
bool IsStartedSetNavIdOnce;
|
||||
bool RequestClear;
|
||||
ImGuiKeyChord KeyMods : 16; // Latched key-mods for box-select logic.
|
||||
ImVec2 StartPosRel; // Start position in window-contents relative space (to support scrolling)
|
||||
|
@ -7161,6 +7161,7 @@ static void BoxSelectPreStartDrag(ImGuiID id, ImGuiSelectionUserData clicked_ite
|
||||
bs->ID = id;
|
||||
bs->IsStarting = true; // Consider starting box-select.
|
||||
bs->IsStartedFromVoid = (clicked_item == ImGuiSelectionUserData_Invalid);
|
||||
bs->IsStartedSetNavIdOnce = bs->IsStartedFromVoid;
|
||||
bs->KeyMods = g.IO.KeyMods;
|
||||
bs->StartPosRel = bs->EndPosRel = ImGui::WindowPosAbsToRel(g.CurrentWindow, g.IO.MousePos);
|
||||
bs->ScrollAccum = ImVec2(0.0f, 0.0f);
|
||||
@ -7682,9 +7683,10 @@ void ImGui::MultiSelectItemFooter(ImGuiID id, bool* p_selected, bool* p_pressed)
|
||||
const bool rect_overlap_prev = bs->BoxSelectRectPrev.Overlaps(g.LastItemData.Rect);
|
||||
if ((rect_overlap_curr && !rect_overlap_prev && !selected) || (rect_overlap_prev && !rect_overlap_curr))
|
||||
{
|
||||
if (storage->LastSelectionSize <= 0 && bs->IsStartedFromVoid)
|
||||
if (storage->LastSelectionSize <= 0 && bs->IsStartedSetNavIdOnce)
|
||||
{
|
||||
pressed = true; // First item act as a pressed: code below will emit selection request and set NavId (whatever we emit here will be overridden anyway)
|
||||
bs->IsStartedSetNavIdOnce = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user