| 8803 | } |
| 8804 | |
| 8805 | void ImGui::SetNavFocusScope(ImGuiID focus_scope_id) |
| 8806 | { |
| 8807 | ImGuiContext& g = *GImGui; |
| 8808 | g.NavFocusScopeId = focus_scope_id; |
| 8809 | g.NavFocusRoute.resize(0); // Invalidate |
| 8810 | if (focus_scope_id == 0) |
| 8811 | return; |
| 8812 | IM_ASSERT(g.NavWindow != NULL); |
| 8813 | |
| 8814 | // Store current path (in reverse order) |
| 8815 | if (focus_scope_id == g.CurrentFocusScopeId) |
| 8816 | { |
| 8817 | // Top of focus stack contains local focus scopes inside current window |
| 8818 | for (int n = g.FocusScopeStack.Size - 1; n >= 0 && g.FocusScopeStack.Data[n].WindowID == g.CurrentWindow->ID; n--) |
| 8819 | g.NavFocusRoute.push_back(g.FocusScopeStack.Data[n]); |
| 8820 | } |
| 8821 | else if (focus_scope_id == g.NavWindow->NavRootFocusScopeId) |
| 8822 | g.NavFocusRoute.push_back({ focus_scope_id, g.NavWindow->ID }); |
| 8823 | else |
| 8824 | return; |
| 8825 | |
| 8826 | // Then follow on manually set ParentWindowForFocusRoute field (#6798) |
| 8827 | for (ImGuiWindow* window = g.NavWindow->ParentWindowForFocusRoute; window != NULL; window = window->ParentWindowForFocusRoute) |
| 8828 | g.NavFocusRoute.push_back({ window->NavRootFocusScopeId, window->ID }); |
| 8829 | IM_ASSERT(g.NavFocusRoute.Size < 100); // Maximum depth is technically 251 as per CalcRoutingScore(): 254 - 3 |
| 8830 | } |
| 8831 | |
| 8832 | // Focus = move navigation cursor, set scrolling, set focus window. |
| 8833 | void ImGui::FocusItem() |