MCPcopy Create free account
hub / github.com/cinder/Cinder / NavUpdateCancelRequest

Method NavUpdateCancelRequest

src/imgui/imgui.cpp:13964–14012  ·  view source on GitHub ↗

Process Escape/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 i

Source from the content-addressed store, hash-verified

13962// - either to store the equivalent of ActiveIdUsingKeyInputMask for a FocusScope and test for it.
13963// - 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
13964static void ImGui::NavUpdateCancelRequest()
13965{
13966 ImGuiContext& g = *GImGui;
13967 const bool nav_gamepad_active = (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (g.IO.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0;
13968 const bool nav_keyboard_active = (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0;
13969 if (!(nav_keyboard_active && IsKeyPressed(ImGuiKey_Escape, 0, ImGuiKeyOwner_NoOwner)) && !(nav_gamepad_active && IsKeyPressed(ImGuiKey_NavGamepadCancel, 0, ImGuiKeyOwner_NoOwner)))
13970 return;
13971
13972 IMGUI_DEBUG_LOG_NAV("[nav] NavUpdateCancelRequest()\n");
13973 if (g.ActiveId != 0)
13974 {
13975 ClearActiveID();
13976 }
13977 else if (g.NavLayer != ImGuiNavLayer_Main)
13978 {
13979 // Leave the "menu" layer
13980 NavRestoreLayer(ImGuiNavLayer_Main);
13981 SetNavCursorVisibleAfterMove();
13982 }
13983 else if (g.NavWindow && g.NavWindow != g.NavWindow->RootWindow && !(g.NavWindow->RootWindowForNav->Flags & ImGuiWindowFlags_Popup) && g.NavWindow->RootWindowForNav->ParentWindow)
13984 {
13985 // Exit child window
13986 ImGuiWindow* child_window = g.NavWindow->RootWindowForNav;
13987 ImGuiWindow* parent_window = child_window->ParentWindow;
13988 IM_ASSERT(child_window->ChildId != 0);
13989 FocusWindow(parent_window);
13990 SetNavID(child_window->ChildId, ImGuiNavLayer_Main, 0, WindowRectAbsToRel(parent_window, child_window->Rect()));
13991 SetNavCursorVisibleAfterMove();
13992 }
13993 else if (g.OpenPopupStack.Size > 0 && g.OpenPopupStack.back().Window != NULL && !(g.OpenPopupStack.back().Window->Flags & ImGuiWindowFlags_Modal))
13994 {
13995 // Close open popup/menu
13996 ClosePopupToLevel(g.OpenPopupStack.Size - 1, true);
13997 }
13998 else
13999 {
14000 // Clear NavLastId for popups but keep it for regular child window so we can leave one and come back where we were
14001 // FIXME-NAV: This should happen on window appearing.
14002 if (g.IO.ConfigNavEscapeClearFocusItem || g.IO.ConfigNavEscapeClearFocusWindow)
14003 if (g.NavWindow && ((g.NavWindow->Flags & ImGuiWindowFlags_Popup)))// || !(g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow)))
14004 g.NavWindow->NavLastIds[0] = 0;
14005
14006 // Clear nav focus
14007 if (g.IO.ConfigNavEscapeClearFocusItem || g.IO.ConfigNavEscapeClearFocusWindow)
14008 g.NavId = 0;
14009 if (g.IO.ConfigNavEscapeClearFocusWindow)
14010 FocusWindow(NULL);
14011 }
14012}
14013
14014// Handle PageUp/PageDown/Home/End keys
14015// Called from NavUpdateCreateMoveRequest() which will use our output to create a move request

Callers

nothing calls this directly

Calls 3

WindowRectAbsToRelFunction · 0.85
backMethod · 0.80
RectMethod · 0.45

Tested by

no test coverage detected