Fix possible undismissed screen keyboard in iOS

This commit is contained in:
Benau 2020-07-17 19:10:53 +08:00
parent 31c1003912
commit f2b774d63a
5 changed files with 25 additions and 2 deletions

View File

@ -610,6 +610,8 @@ public:
//! reads an element
virtual void readGUIElement(io::IXMLReader* reader, IGUIElement* node) =0;
virtual void removeHovered(IGUIElement* element) = 0;
};

View File

@ -1617,6 +1617,21 @@ IGUIElement* CGUIEnvironment::getNextElement(bool reverse, bool group)
}
void CGUIEnvironment::removeHovered(IGUIElement* element)
{
if (Hovered && Hovered == element)
{
Hovered->drop();
Hovered = NULL;
if (HoveredNoSubelement)
{
HoveredNoSubelement->drop();
HoveredNoSubelement = NULL;
}
}
}
//! creates an GUI Environment
IGUIEnvironment* createGUIEnvironment(io::IFileSystem* fs,
video::IVideoDriver* Driver,

View File

@ -256,6 +256,7 @@ public:
//! reads an element
virtual void readGUIElement(io::IXMLReader* reader, IGUIElement* node);
virtual void removeHovered(IGUIElement* element);
private:
IGUIElement* getNextElement(bool reverse=false, bool group=false);

View File

@ -242,6 +242,7 @@ CGUIEditBox::~CGUIEditBox()
GUIEngine::ScreenKeyboard::hasSystemScreenKeyboard())
Android_toggleOnScreenKeyboard(false, 0, 0);
#elif defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
if (SDL_IsTextInputActive())
SDL_StopTextInput();
#endif
@ -366,6 +367,7 @@ bool CGUIEditBox::OnEvent(const SEvent& event)
setTextMarkers(0,0);
}
#if !defined(ANDROID) && defined(_IRR_COMPILE_WITH_SDL_DEVICE_)
if (SDL_IsTextInputActive())
SDL_StopTextInput();
#endif
#ifdef ANDROID

View File

@ -199,6 +199,9 @@ void TextBoxWidget::unfocused(const int playerID, Widget* new_focus)
void TextBoxWidget::elementRemoved()
{
// If text box is destroyed without moving mouse out of its focus, the
// reference will be kept so we clear it manually
GUIEngine::getGUIEnv()->removeHovered(m_element);
// normally at this point normal widgets have been deleted by irrlicht already.
// but this is a custom widget and the gui env does not appear to want to
// manage it. so we free it manually