File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1872,10 +1872,26 @@ namespace MWGui
18721872
18731873 void WindowManager::onKeyFocusChanged (MyGUI::Widget* widget)
18741874 {
1875- bool isEditBox = widget && widget->castType <MyGUI::EditBox>(false );
1876- LuaUi::WidgetExtension* luaWidget = dynamic_cast <LuaUi::WidgetExtension*>(widget);
1877- bool capturesInput = luaWidget ? luaWidget->isTextInput () : isEditBox;
1878- if (widget && capturesInput)
1875+ bool capturesInput = false ;
1876+ if (widget)
1877+ {
1878+ LuaUi::WidgetExtension* luaWidget = dynamic_cast <LuaUi::WidgetExtension*>(widget);
1879+ if (luaWidget)
1880+ capturesInput = luaWidget->isTextInput ();
1881+ else
1882+ capturesInput = widget->castType <MyGUI::EditBox>(false );
1883+ }
1884+
1885+ // The SDL_IsTextInputActive() check helps to avoid duplicate calls in SDL2.
1886+ // This may no longer be required when switching to SDL3 where the function
1887+ // has also been renamed to SDL_TextInputActive() and returns bool instead
1888+ // of SDL_bool.
1889+
1890+ const bool inputActive = SDL_IsTextInputActive () == SDL_TRUE;
1891+ if (capturesInput == inputActive)
1892+ return ;
1893+
1894+ if (capturesInput)
18791895 SDL_StartTextInput ();
18801896 else
18811897 SDL_StopTextInput ();
You can’t perform that action at this time.
0 commit comments