diff options
author | oy <tom_adams@web.de> | 2023-06-29 21:09:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-29 21:09:53 +0200 |
commit | d90dcadc75854163f3aa6e145ecea0e01e80a5c1 (patch) | |
tree | c5dc118eb8de822c6a74b12b21748e9f29fe0b0f | |
parent | 8a18e656c9348995540d9b937d98ea3493098094 (diff) | |
parent | d141f0f055d846939ab48bd29eb0f0aa66a65c0c (diff) |
Merge pull request #3206 from Robyt3/CLineInput-Deactivate-If-Not-Rendered
Ensure line inputs are deactivated when they are not rendered
-rw-r--r-- | src/game/client/lineinput.cpp | 19 | ||||
-rw-r--r-- | src/game/client/lineinput.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/game/client/lineinput.cpp b/src/game/client/lineinput.cpp index ff6752f36..5c086aaf9 100644 --- a/src/game/client/lineinput.cpp +++ b/src/game/client/lineinput.cpp @@ -36,6 +36,7 @@ void CLineInput::SetBuffer(char *pStr, int MaxSize, int MaxChars) m_ScrollOffset = m_ScrollOffsetChange = 0.0f; m_CaretPosition = vec2(0, 0); m_Hidden = false; + m_WasRendered = false; } if(m_pStr && m_pStr != pLastStr) UpdateStrData(); @@ -355,6 +356,7 @@ bool CLineInput::ProcessInput(const IInput::CEvent &Event) void CLineInput::Render(bool Changed) { + m_WasRendered = true; m_TextCursor.Reset(); if(!m_pStr) @@ -423,6 +425,23 @@ void CLineInput::Render(bool Changed) void CLineInput::RenderCandidates() { + // Check if the active line input was not rendered and deactivate it in that case. + // This can happen e.g. when an input in the ingame menu is active and the menu is + // closed or when switching between menu and editor with an active input. + CLineInput *pActiveInput = GetActiveInput(); + if(pActiveInput != nullptr) + { + if(pActiveInput->m_WasRendered) + { + pActiveInput->m_WasRendered = false; + } + else + { + pActiveInput->Deactivate(); + return; + } + } + if(!s_pInput->HasComposition() || !s_pInput->GetCandidateCount()) return; diff --git a/src/game/client/lineinput.h b/src/game/client/lineinput.h index 6ab4d5d46..b0945c40d 100644 --- a/src/game/client/lineinput.h +++ b/src/game/client/lineinput.h @@ -51,6 +51,7 @@ class CLineInput bool m_Hidden; bool m_WasChanged; + bool m_WasRendered; void UpdateStrData(); enum EMoveDirection |