set default focus on chat
This commit is contained in:
@@ -13,6 +13,7 @@ class GameChatGui : public GuiWidget, ChatListener {
|
||||
private:
|
||||
char InputBuf[256];
|
||||
std::vector<std::string> Items;
|
||||
bool m_FocusRequested = false;
|
||||
|
||||
void Draw(const char* title, bool* p_open);
|
||||
|
||||
|
||||
@@ -34,6 +34,11 @@ void GameChatGui::Draw(const char* title, bool* p_open) {
|
||||
ImGui::EndChild();
|
||||
ImGuiInputTextFlags input_text_flags = ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_EscapeClearsAll;
|
||||
|
||||
if (m_FocusRequested) {
|
||||
ImGui::SetKeyboardFocusHere(0);
|
||||
m_FocusRequested = false;
|
||||
}
|
||||
|
||||
ImGui::SetNextItemWidth(chatInput_width);
|
||||
if (ImGui::InputText(" ", InputBuf, IM_ARRAYSIZE(InputBuf), input_text_flags)) {
|
||||
utils::LOG(InputBuf);
|
||||
@@ -51,6 +56,7 @@ void GameChatGui::Render() {
|
||||
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_Enter)) {
|
||||
showCHAT = true;
|
||||
m_FocusRequested = true;
|
||||
} else if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
||||
showCHAT = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user