Skip to content

Commit

Permalink
Merge pull request teeworlds#3206 from Robyt3/CLineInput-Deactivate-I…
Browse files Browse the repository at this point in the history
…f-Not-Rendered

Ensure line inputs are deactivated when they are not rendered
  • Loading branch information
oy authored Jun 29, 2023
2 parents 8a18e65 + d141f0f commit d90dcad
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 d90dcad

Please sign in to comment.