Skip to content

Commit

Permalink
Merge Improve keyboard focus (pr-2886)
Browse files Browse the repository at this point in the history
62bce91 - tweak(console): Improve keyboard focus
  • Loading branch information
prikolium-cfx committed Oct 29, 2024
2 parents 2632c6d + 62bce91 commit 9cac14f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions code/components/conhost-v2/src/ConsoleHostGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,6 @@ struct CfxBigConsole : FiveMConsoleBase

// Input field in the first column
ImGui::PushItemWidth(-FLT_MIN);
bool reclaim_focus = false;
if (ImGui::InputText("##_Input", InputBuf, _countof(InputBuf),
ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory, &TextEditCallbackStub, (void*)this))
{
Expand All @@ -417,7 +416,6 @@ struct CfxBigConsole : FiveMConsoleBase
if (InputBuf[0])
ExecCommand(InputBuf);
strcpy(InputBuf, "");
reclaim_focus = true;
}
ImGui::PopItemWidth();

Expand All @@ -431,6 +429,11 @@ struct CfxBigConsole : FiveMConsoleBase
{
OpenLogFile();
shouldOpenLog = false;
}

if (ImGui::IsItemHovered() || (ImGui::IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) && !ImGui::IsAnyItemActive() && !ImGui::IsMouseClicked(0)))
{
ImGui::SetKeyboardFocusHere(-1);
}

bool preAutoScrollValue = AutoScrollEnabled;
Expand Down

0 comments on commit 9cac14f

Please sign in to comment.