Skip to content

Commit

Permalink
Comment on invalid comment regarding preserving keyboard focus of a c…
Browse files Browse the repository at this point in the history
…losed window, due to commit 19d02be. This is probably still what we want. (followup #727)
  • Loading branch information
ocornut committed Jul 18, 2016
1 parent eb405ab commit 23a8102
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1924,10 +1924,7 @@ bool ImGui::FocusableItemRegister(ImGuiWindow* window, bool is_active, bool tab_
// Process keyboard input at this point: TAB, Shift-TAB switch focus
// We can always TAB out of a widget that doesn't allow tabbing in.
if (tab_stop && window->FocusIdxAllRequestNext == INT_MAX && window->FocusIdxTabRequestNext == INT_MAX && is_active && !g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab))
{
// Modulo on index will be applied at the end of frame once we've got the total counter of items.
window->FocusIdxTabRequestNext = window->FocusIdxTabCounter + (g.IO.KeyShift ? (allow_keyboard_focus ? -1 : 0) : +1);
}
window->FocusIdxTabRequestNext = window->FocusIdxTabCounter + (g.IO.KeyShift ? (allow_keyboard_focus ? -1 : 0) : +1); // Modulo on index will be applied at the end of frame once we've got the total counter of items.

if (window->FocusIdxAllCounter == window->FocusIdxAllRequestCurrent)
return true;
Expand Down Expand Up @@ -2267,7 +2264,7 @@ void ImGui::NewFrame()
}

// Pressing TAB activate widget focus
// NB: Don't discard FocusedWindow if it isn't active, so that a window that go on/off programatically won't lose its keyboard focus.
//// NB: Don't discard FocusedWindow if it isn't active, so that a window that go on/off programatically won't lose its keyboard focus. // [2016/07/17] That comment was made invalid by 19d02becef94e8e0f1d432a8bd55cd783876583c
if (g.ActiveId == 0 && g.FocusedWindow != NULL && g.FocusedWindow->Active && !g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab, false))
g.FocusedWindow->FocusIdxTabRequestNext = 0;

Expand Down

0 comments on commit 23a8102

Please sign in to comment.