mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #6671
6671: Ensure line inputs are deactivated when they are not rendered r=def- a=Robyt3 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. Closes #6666. ## Checklist - [X] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test (especially base/) or added coverage to integration test - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: Robert Müller <robytemueller@gmail.com>
This commit is contained in:
commit
144bb1dd7f
|
@ -34,6 +34,7 @@ void CLineInput::SetBuffer(char *pStr, size_t MaxSize, size_t MaxChars)
|
|||
m_Hidden = false;
|
||||
m_pEmptyText = nullptr;
|
||||
m_MouseSelection.m_Selecting = false;
|
||||
m_WasRendered = false;
|
||||
}
|
||||
if(m_pStr && m_pStr != pLastStr)
|
||||
UpdateStrData();
|
||||
|
@ -401,6 +402,8 @@ bool CLineInput::ProcessInput(const IInput::CEvent &Event)
|
|||
|
||||
STextBoundingBox CLineInput::Render(const CUIRect *pRect, float FontSize, int Align, bool Changed, float LineWidth)
|
||||
{
|
||||
m_WasRendered = true;
|
||||
|
||||
const char *pDisplayStr = GetDisplayedString();
|
||||
const bool HasComposition = Input()->HasComposition();
|
||||
|
||||
|
@ -528,6 +531,23 @@ STextBoundingBox CLineInput::Render(const CUIRect *pRect, float FontSize, int Al
|
|||
|
||||
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(!Input()->HasComposition() || !Input()->GetCandidateCount())
|
||||
return;
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ private:
|
|||
const char *m_pEmptyText;
|
||||
FClipboardLineCallback m_pfnClipboardLineCallback;
|
||||
bool m_WasChanged;
|
||||
bool m_WasRendered;
|
||||
|
||||
char m_ClearButtonId;
|
||||
|
||||
|
|
Loading…
Reference in a new issue