From 4b957d817c26f66cefcb83652cd98d0ff57320e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Fri, 2 Feb 2024 12:08:04 +0100 Subject: [PATCH] chat improvements --- code/client/src/core/ui/chat.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/code/client/src/core/ui/chat.cpp b/code/client/src/core/ui/chat.cpp index 4ee4c530..4fba896c 100644 --- a/code/client/src/core/ui/chat.cpp +++ b/code/client/src/core/ui/chat.cpp @@ -26,6 +26,8 @@ namespace MafiaMP::Core::UI { _newMsgArrived = false; } + bool _wasFocused = _isFocused; + if (gApplication->GetInput()->IsKeyPressed(FW_KEY_RETURN) && !_isFocused) { _isFocused = true; gApplication->LockControls(true); @@ -75,14 +77,16 @@ namespace MafiaMP::Core::UI { return 0; }; - if (ImGui::InputText("##chatinput", _inputText, sizeof(_inputText), ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_CallbackHistory, Framework::External::ImGUI::getCallback(inputEditCallback), &inputEditCallback)) { - _isFocused = false; + ImGui::InputText("##chatinput", _inputText, sizeof(_inputText), ImGuiInputTextFlags_CallbackHistory, Framework::External::ImGUI::getCallback(inputEditCallback), &inputEditCallback); + + if (_wasFocused && gApplication->GetInput()->IsKeyPressed(FW_KEY_RETURN)) { if (strlen(_inputText)) { onMessageSentProc(_inputText); _history.emplace(_history.begin(), _inputText); strcpy(_inputText, ""); } + _isFocused = false; gApplication->LockControls(false); if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) ImGui::SetScrollHereY(1.0f);