MultiSelect: clear selection when leaving a scope with a nav directional request.
May need to clarify how to depends on actions being performed (e.g. click doesn't). May become optional?
This commit is contained in:
@@ -12251,6 +12251,7 @@ static void ImGui::NavUpdate()
|
|||||||
|
|
||||||
// Process navigation init request (select first/default focus)
|
// Process navigation init request (select first/default focus)
|
||||||
g.NavJustMovedToId = 0;
|
g.NavJustMovedToId = 0;
|
||||||
|
g.NavJustMovedToFocusScopeId = g.NavJustMovedFromFocusScopeId = 0;
|
||||||
if (g.NavInitResult.ID != 0)
|
if (g.NavInitResult.ID != 0)
|
||||||
NavInitRequestApplyResult();
|
NavInitRequestApplyResult();
|
||||||
g.NavInitRequest = false;
|
g.NavInitRequest = false;
|
||||||
@@ -12403,6 +12404,7 @@ void ImGui::NavInitRequestApplyResult()
|
|||||||
ImGuiNavItemData* result = &g.NavInitResult;
|
ImGuiNavItemData* result = &g.NavInitResult;
|
||||||
if (g.NavId != result->ID)
|
if (g.NavId != result->ID)
|
||||||
{
|
{
|
||||||
|
g.NavJustMovedFromFocusScopeId = g.NavFocusScopeId;
|
||||||
g.NavJustMovedToId = result->ID;
|
g.NavJustMovedToId = result->ID;
|
||||||
g.NavJustMovedToFocusScopeId = result->FocusScopeId;
|
g.NavJustMovedToFocusScopeId = result->FocusScopeId;
|
||||||
g.NavJustMovedToKeyMods = 0;
|
g.NavJustMovedToKeyMods = 0;
|
||||||
@@ -12661,6 +12663,7 @@ void ImGui::NavMoveRequestApplyResult()
|
|||||||
// PageUp/PageDown however sets always set NavJustMovedTo (vs Home/End which doesn't) mimicking Windows behavior.
|
// PageUp/PageDown however sets always set NavJustMovedTo (vs Home/End which doesn't) mimicking Windows behavior.
|
||||||
if ((g.NavId != result->ID || (g.NavMoveFlags & ImGuiNavMoveFlags_IsPageMove)) && (g.NavMoveFlags & ImGuiNavMoveFlags_NoSelect) == 0)
|
if ((g.NavId != result->ID || (g.NavMoveFlags & ImGuiNavMoveFlags_IsPageMove)) && (g.NavMoveFlags & ImGuiNavMoveFlags_NoSelect) == 0)
|
||||||
{
|
{
|
||||||
|
g.NavJustMovedFromFocusScopeId = g.NavFocusScopeId;
|
||||||
g.NavJustMovedToId = result->ID;
|
g.NavJustMovedToId = result->ID;
|
||||||
g.NavJustMovedToFocusScopeId = result->FocusScopeId;
|
g.NavJustMovedToFocusScopeId = result->FocusScopeId;
|
||||||
g.NavJustMovedToKeyMods = g.NavMoveKeyMods;
|
g.NavJustMovedToKeyMods = g.NavMoveKeyMods;
|
||||||
|
|||||||
+10
-4
@@ -7165,10 +7165,7 @@ ImGuiMultiSelectIO* ImGui::BeginMultiSelect(ImGuiMultiSelectFlags flags)
|
|||||||
ms->BeginIO.NavIdItem = ms->EndIO.NavIdItem = storage->NavIdItem;
|
ms->BeginIO.NavIdItem = ms->EndIO.NavIdItem = storage->NavIdItem;
|
||||||
ms->BeginIO.NavIdSelected = ms->EndIO.NavIdSelected = (storage->NavIdSelected == 1) ? true : false;
|
ms->BeginIO.NavIdSelected = ms->EndIO.NavIdSelected = (storage->NavIdSelected == 1) ? true : false;
|
||||||
|
|
||||||
if (!ms->IsFocused)
|
// Clear when using Navigation to move within the scope
|
||||||
return &ms->BeginIO; // This is cleared at this point.
|
|
||||||
|
|
||||||
// Auto clear when using Navigation to move within the selection
|
|
||||||
// (we compare FocusScopeId so it possible to use multiple selections inside a same window)
|
// (we compare FocusScopeId so it possible to use multiple selections inside a same window)
|
||||||
if (g.NavJustMovedToId != 0 && g.NavJustMovedToFocusScopeId == ms->FocusScopeId && g.NavJustMovedToHasSelectionData)
|
if (g.NavJustMovedToId != 0 && g.NavJustMovedToFocusScopeId == ms->FocusScopeId && g.NavJustMovedToHasSelectionData)
|
||||||
{
|
{
|
||||||
@@ -7179,7 +7176,15 @@ ImGuiMultiSelectIO* ImGui::BeginMultiSelect(ImGuiMultiSelectFlags flags)
|
|||||||
if ((ms->KeyMods & (ImGuiMod_Ctrl | ImGuiMod_Shift)) == 0)
|
if ((ms->KeyMods & (ImGuiMod_Ctrl | ImGuiMod_Shift)) == 0)
|
||||||
ms->BeginIO.RequestClear = true;
|
ms->BeginIO.RequestClear = true;
|
||||||
}
|
}
|
||||||
|
else if (g.NavJustMovedFromFocusScopeId == ms->FocusScopeId)
|
||||||
|
{
|
||||||
|
// Also clear on leaving scope (may be optional?)
|
||||||
|
if ((ms->KeyMods & (ImGuiMod_Ctrl | ImGuiMod_Shift)) == 0)
|
||||||
|
ms->BeginIO.RequestClear = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ms->IsFocused)
|
||||||
|
{
|
||||||
// Shortcut: Select all (CTRL+A)
|
// Shortcut: Select all (CTRL+A)
|
||||||
if (!(flags & ImGuiMultiSelectFlags_SingleSelect) && !(flags & ImGuiMultiSelectFlags_NoSelectAll))
|
if (!(flags & ImGuiMultiSelectFlags_SingleSelect) && !(flags & ImGuiMultiSelectFlags_NoSelectAll))
|
||||||
if (Shortcut(ImGuiMod_Ctrl | ImGuiKey_A))
|
if (Shortcut(ImGuiMod_Ctrl | ImGuiKey_A))
|
||||||
@@ -7191,6 +7196,7 @@ ImGuiMultiSelectIO* ImGui::BeginMultiSelect(ImGuiMultiSelectFlags flags)
|
|||||||
if (flags & ImGuiMultiSelectFlags_ClearOnEscape)
|
if (flags & ImGuiMultiSelectFlags_ClearOnEscape)
|
||||||
if (Shortcut(ImGuiKey_Escape))
|
if (Shortcut(ImGuiKey_Escape))
|
||||||
ms->BeginIO.RequestClear = true;
|
ms->BeginIO.RequestClear = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (g.DebugLogFlags & ImGuiDebugLogFlags_EventSelection)
|
if (g.DebugLogFlags & ImGuiDebugLogFlags_EventSelection)
|
||||||
DebugLogMultiSelectRequests("BeginMultiSelect", &ms->BeginIO);
|
DebugLogMultiSelectRequests("BeginMultiSelect", &ms->BeginIO);
|
||||||
|
|||||||
Reference in New Issue
Block a user