MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / NavUpdateCancelRequest

Method NavUpdateCancelRequest

KBotExt/imgui/imgui.cpp:11822–11864  ·  view source on GitHub ↗

Process NavCancel input (to close a popup, get back to parent, clear focus) FIXME: In order to support e.g. Escape to clear a selection we'll need: - either to store the equivalent of ActiveIdUsingKeyInputMask for a FocusScope and test for it. - either to move most/all of those tests to the epilogue/end functions of the scope they are dealing with (e.g. exit child window in EndChild()) or in EndFr

Source from the content-addressed store, hash-verified

11820// - either to store the equivalent of ActiveIdUsingKeyInputMask for a FocusScope and test for it.
11821// - either to move most/all of those tests to the epilogue/end functions of the scope they are dealing with (e.g. exit child window in EndChild()) or in EndFrame(), to allow an earlier intercept
11822static void ImGui::NavUpdateCancelRequest()
11823{
11824 ImGuiContext& g = *GImGui;
11825 const bool nav_gamepad_active = (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (g.IO.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0;
11826 const bool nav_keyboard_active = (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0;
11827 if (!(nav_keyboard_active && IsKeyPressed(ImGuiKey_Escape, ImGuiKeyOwner_None)) && !(nav_gamepad_active && IsKeyPressed(ImGuiKey_NavGamepadCancel, ImGuiKeyOwner_None)))
11828 return;
11829
11830 IMGUI_DEBUG_LOG_NAV("[nav] NavUpdateCancelRequest()\n");
11831 if (g.ActiveId != 0)
11832 {
11833 ClearActiveID();
11834 }
11835 else if (g.NavLayer != ImGuiNavLayer_Main)
11836 {
11837 // Leave the "menu" layer
11838 NavRestoreLayer(ImGuiNavLayer_Main);
11839 NavRestoreHighlightAfterMove();
11840 }
11841 else if (g.NavWindow && g.NavWindow != g.NavWindow->RootWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_Popup) && g.NavWindow->ParentWindow)
11842 {
11843 // Exit child window
11844 ImGuiWindow* child_window = g.NavWindow;
11845 ImGuiWindow* parent_window = g.NavWindow->ParentWindow;
11846 IM_ASSERT(child_window->ChildId != 0);
11847 ImRect child_rect = child_window->Rect();
11848 FocusWindow(parent_window);
11849 SetNavID(child_window->ChildId, ImGuiNavLayer_Main, 0, WindowRectAbsToRel(parent_window, child_rect));
11850 NavRestoreHighlightAfterMove();
11851 }
11852 else if (g.OpenPopupStack.Size > 0 && g.OpenPopupStack.back().Window != NULL && !(g.OpenPopupStack.back().Window->Flags & ImGuiWindowFlags_Modal))
11853 {
11854 // Close open popup/menu
11855 ClosePopupToLevel(g.OpenPopupStack.Size - 1, true);
11856 }
11857 else
11858 {
11859 // Clear NavLastId for popups but keep it for regular child window so we can leave one and come back where we were
11860 if (g.NavWindow && ((g.NavWindow->Flags & ImGuiWindowFlags_Popup) || !(g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow)))
11861 g.NavWindow->NavLastIds[0] = 0;
11862 g.NavId = 0;
11863 }
11864}
11865
11866// Handle PageUp/PageDown/Home/End keys
11867// Called from NavUpdateCreateMoveRequest() which will use our output to create a move request

Callers

nothing calls this directly

Calls 1

WindowRectAbsToRelFunction · 0.85

Tested by

no test coverage detected