Nav, Focus: Changed SetKeyboardFocusHere() to not behave if a drag or window moving is in progress + move KeepAliveID() call from Scrollbar() to ScrollbarEx()

This commit is contained in:
ocornut
2022-06-15 14:55:45 +02:00
parent ddcff10343
commit 27343efb0b
3 changed files with 14 additions and 2 deletions

View File

@ -7386,6 +7386,17 @@ void ImGui::SetKeyboardFocusHere(int offset)
IM_ASSERT(offset >= -1); // -1 is allowed but not below
IMGUI_DEBUG_LOG_ACTIVEID("SetKeyboardFocusHere(%d) in window \"%s\"\n", offset, window->Name);
// It makes sense in the vast majority of cases to never interrupt a drag and drop.
// When we refactor this function into ActivateItem() we may want to make this an option.
// Note that g.ActiveId being stolen while g.MovingWindow != NULL is currently ill-defined (subtle side-effects on master, assert in docking),
// so there's another layer we need to fix. Would make sense to automatically drop g.MovingWindow when g.ActiveId is changed.
// MovingWindow is protected from most user inputs using SetActiveIdUsingNavAndKeys() but we may need to enforce a better more encompassing scheme.
if (g.DragDropActive || g.MovingWindow != NULL)
{
IMGUI_DEBUG_LOG_ACTIVEID("SetKeyboardFocusHere() ignored while DragDropActive!\n");
return;
}
SetNavWindow(window);
ImGuiScrollFlags scroll_flags = window->Appearing ? ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleEdgeY;