diff options
-rw-r--r-- | src/game/client/lineinput.cpp | 23 | ||||
-rw-r--r-- | src/game/client/lineinput.h | 1 |
2 files changed, 22 insertions, 2 deletions
diff --git a/src/game/client/lineinput.cpp b/src/game/client/lineinput.cpp index 2b6538e67..bddae50a3 100644 --- a/src/game/client/lineinput.cpp +++ b/src/game/client/lineinput.cpp @@ -37,6 +37,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(); @@ -222,7 +223,7 @@ bool CLineInput::ProcessInput(const IInput::CEvent &Event) if(Event.m_Key == KEY_BACKSPACE) { - if(SelectionLength && !MoveWord) + if(SelectionLength) { SetRange("", m_SelectionStart, m_SelectionEnd); } @@ -242,7 +243,7 @@ bool CLineInput::ProcessInput(const IInput::CEvent &Event) } else if(Event.m_Key == KEY_DELETE) { - if(SelectionLength && !MoveWord) + if(SelectionLength) { SetRange("", m_SelectionStart, m_SelectionEnd); } @@ -356,6 +357,7 @@ bool CLineInput::ProcessInput(const IInput::CEvent &Event) void CLineInput::Render(bool Changed) { + m_WasRendered = true; m_TextCursor.Reset(); if(!m_pStr) @@ -424,6 +426,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 |