Skip to content

Commit

Permalink
chat improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
zpl-zak committed Feb 2, 2024
1 parent ecf8c60 commit 4b957d8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions code/client/src/core/ui/chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4b957d8

Please sign in to comment.