Skip to content

Commit

Permalink
Ensure line inputs are deactivated when they are not rendered
Browse files Browse the repository at this point in the history
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.

This was causing the IME candidate list to be rendered ingame after closing the menu.
  • Loading branch information
Robyt3 committed Jun 26, 2023
1 parent 8a18e65 commit d141f0f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/game/client/lineinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/game/client/lineinput.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class CLineInput

bool m_Hidden;
bool m_WasChanged;
bool m_WasRendered;

void UpdateStrData();
enum EMoveDirection
Expand Down

0 comments on commit d141f0f

Please sign in to comment.