|
@@ -3251,18 +3251,18 @@ bool ImGui::FocusableItemRegister(ImGuiWindow* window, ImGuiID id)
|
|
|
|
|
|
// Process TAB/Shift-TAB to tab *OUT* of the currently focused item.
|
|
|
// (Note that we can always TAB out of a widget that doesn't allow tabbing in)
|
|
|
- if (g.ActiveId == id && g.FocusTabPressed && !IsActiveIdUsingKey(ImGuiKey_Tab) && g.FocusRequestNextWindow == NULL)
|
|
|
+ if (g.ActiveId == id && g.TabFocusPressed && !IsActiveIdUsingKey(ImGuiKey_Tab) && g.TabFocusRequestNextWindow == NULL)
|
|
|
{
|
|
|
- g.FocusRequestNextWindow = window;
|
|
|
- g.FocusRequestNextCounterTabStop = window->DC.FocusCounterTabStop + (g.IO.KeyShift ? (is_tab_stop ? -1 : 0) : +1); // Modulo on index will be applied at the end of frame once we've got the total counter of items.
|
|
|
+ g.TabFocusRequestNextWindow = window;
|
|
|
+ g.TabFocusRequestNextCounterTabStop = window->DC.FocusCounterTabStop + (g.IO.KeyShift ? (is_tab_stop ? -1 : 0) : +1); // Modulo on index will be applied at the end of frame once we've got the total counter of items.
|
|
|
}
|
|
|
|
|
|
// Handle focus requests
|
|
|
- if (g.FocusRequestCurrWindow == window)
|
|
|
+ if (g.TabFocusRequestCurrWindow == window)
|
|
|
{
|
|
|
- if (window->DC.FocusCounterRegular == g.FocusRequestCurrCounterRegular)
|
|
|
+ if (window->DC.FocusCounterRegular == g.TabFocusRequestCurrCounterRegular)
|
|
|
return true;
|
|
|
- if (is_tab_stop && window->DC.FocusCounterTabStop == g.FocusRequestCurrCounterTabStop)
|
|
|
+ if (is_tab_stop && window->DC.FocusCounterTabStop == g.TabFocusRequestCurrCounterTabStop)
|
|
|
{
|
|
|
g.NavJustTabbedId = id;
|
|
|
return true;
|
|
@@ -3768,32 +3768,32 @@ void ImGui::UpdateTabFocus()
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
|
|
|
// Pressing TAB activate widget focus
|
|
|
- g.FocusTabPressed = (g.NavWindow && g.NavWindow->Active && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) && !g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab));
|
|
|
- if (g.ActiveId == 0 && g.FocusTabPressed)
|
|
|
+ g.TabFocusPressed = (g.NavWindow && g.NavWindow->Active && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) && !g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab));
|
|
|
+ if (g.ActiveId == 0 && g.TabFocusPressed)
|
|
|
{
|
|
|
// Note that SetKeyboardFocusHere() sets the Next fields mid-frame. To be consistent we also
|
|
|
// manipulate the Next fields even, even though they will be turned into Curr fields by the code below.
|
|
|
- g.FocusRequestNextWindow = g.NavWindow;
|
|
|
- g.FocusRequestNextCounterRegular = INT_MAX;
|
|
|
+ g.TabFocusRequestNextWindow = g.NavWindow;
|
|
|
+ g.TabFocusRequestNextCounterRegular = INT_MAX;
|
|
|
if (g.NavId != 0 && g.NavIdTabCounter != INT_MAX)
|
|
|
- g.FocusRequestNextCounterTabStop = g.NavIdTabCounter + 1 + (g.IO.KeyShift ? -1 : 1);
|
|
|
+ g.TabFocusRequestNextCounterTabStop = g.NavIdTabCounter + 1 + (g.IO.KeyShift ? -1 : 1);
|
|
|
else
|
|
|
- g.FocusRequestNextCounterTabStop = g.IO.KeyShift ? -1 : 0;
|
|
|
+ g.TabFocusRequestNextCounterTabStop = g.IO.KeyShift ? -1 : 0;
|
|
|
}
|
|
|
|
|
|
// Turn queued focus request into current one
|
|
|
- g.FocusRequestCurrWindow = NULL;
|
|
|
- g.FocusRequestCurrCounterRegular = g.FocusRequestCurrCounterTabStop = INT_MAX;
|
|
|
- if (g.FocusRequestNextWindow != NULL)
|
|
|
+ g.TabFocusRequestCurrWindow = NULL;
|
|
|
+ g.TabFocusRequestCurrCounterRegular = g.TabFocusRequestCurrCounterTabStop = INT_MAX;
|
|
|
+ if (g.TabFocusRequestNextWindow != NULL)
|
|
|
{
|
|
|
- ImGuiWindow* window = g.FocusRequestNextWindow;
|
|
|
- g.FocusRequestCurrWindow = window;
|
|
|
- if (g.FocusRequestNextCounterRegular != INT_MAX && window->DC.FocusCounterRegular != -1)
|
|
|
- g.FocusRequestCurrCounterRegular = ImModPositive(g.FocusRequestNextCounterRegular, window->DC.FocusCounterRegular + 1);
|
|
|
- if (g.FocusRequestNextCounterTabStop != INT_MAX && window->DC.FocusCounterTabStop != -1)
|
|
|
- g.FocusRequestCurrCounterTabStop = ImModPositive(g.FocusRequestNextCounterTabStop, window->DC.FocusCounterTabStop + 1);
|
|
|
- g.FocusRequestNextWindow = NULL;
|
|
|
- g.FocusRequestNextCounterRegular = g.FocusRequestNextCounterTabStop = INT_MAX;
|
|
|
+ ImGuiWindow* window = g.TabFocusRequestNextWindow;
|
|
|
+ g.TabFocusRequestCurrWindow = window;
|
|
|
+ if (g.TabFocusRequestNextCounterRegular != INT_MAX && window->DC.FocusCounterRegular != -1)
|
|
|
+ g.TabFocusRequestCurrCounterRegular = ImModPositive(g.TabFocusRequestNextCounterRegular, window->DC.FocusCounterRegular + 1);
|
|
|
+ if (g.TabFocusRequestNextCounterTabStop != INT_MAX && window->DC.FocusCounterTabStop != -1)
|
|
|
+ g.TabFocusRequestCurrCounterTabStop = ImModPositive(g.TabFocusRequestNextCounterTabStop, window->DC.FocusCounterTabStop + 1);
|
|
|
+ g.TabFocusRequestNextWindow = NULL;
|
|
|
+ g.TabFocusRequestNextCounterRegular = g.TabFocusRequestNextCounterTabStop = INT_MAX;
|
|
|
}
|
|
|
|
|
|
g.NavIdTabCounter = INT_MAX;
|
|
@@ -5886,7 +5886,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
{
|
|
|
window->Collapsed = !window->Collapsed;
|
|
|
MarkIniSettingsDirty(window);
|
|
|
- FocusWindow(window);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -6222,7 +6221,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
if (want_focus)
|
|
|
{
|
|
|
FocusWindow(window);
|
|
|
- NavInitWindow(window, false);
|
|
|
+ NavInitWindow(window, false); // <-- this is in the way for us to be able to defer and sort reappearing FocusWindow() calls
|
|
|
}
|
|
|
|
|
|
// Title bar
|
|
@@ -6924,9 +6923,9 @@ void ImGui::SetKeyboardFocusHere(int offset)
|
|
|
IM_ASSERT(offset >= -1); // -1 is allowed but not below
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
|
- g.FocusRequestNextWindow = window;
|
|
|
- g.FocusRequestNextCounterRegular = window->DC.FocusCounterRegular + 1 + offset;
|
|
|
- g.FocusRequestNextCounterTabStop = INT_MAX;
|
|
|
+ g.TabFocusRequestNextWindow = window;
|
|
|
+ g.TabFocusRequestNextCounterRegular = window->DC.FocusCounterRegular + 1 + offset;
|
|
|
+ g.TabFocusRequestNextCounterTabStop = INT_MAX;
|
|
|
}
|
|
|
|
|
|
void ImGui::SetItemDefaultFocus()
|