Fixed an issue where SDL_StartTextInput() was sometimes set when not actually inputting any text

This commit is contained in:
Leon Styhre 2023-07-20 16:03:59 +02:00
parent bd591a74cb
commit be2b761356
3 changed files with 8 additions and 0 deletions

View file

@ -59,6 +59,7 @@ void InputManager::init()
SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER); SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER);
SDL_GameControllerEventState(SDL_ENABLE); SDL_GameControllerEventState(SDL_ENABLE);
SDL_StopTextInput();
if (!Utils::FileSystem::exists(getConfigPath())) { if (!Utils::FileSystem::exists(getConfigPath())) {
LOG(LogInfo) << "No input configuration file found, default mappings will be applied"; LOG(LogInfo) << "No input configuration file found, default mappings will be applied";

View file

@ -37,6 +37,12 @@ TextEditComponent::TextEditComponent()
setSize(4096, mFont->getHeight() + (TEXT_PADDING_VERT * mRenderer->getScreenHeightModifier())); setSize(4096, mFont->getHeight() + (TEXT_PADDING_VERT * mRenderer->getScreenHeightModifier()));
} }
TextEditComponent::~TextEditComponent()
{
// Always disable text input when destroying this component.
SDL_StopTextInput();
}
void TextEditComponent::onFocusGained() void TextEditComponent::onFocusGained()
{ {
mFocused = true; mFocused = true;

View file

@ -21,6 +21,7 @@ class TextEditComponent : public GuiComponent
{ {
public: public:
TextEditComponent(); TextEditComponent();
~TextEditComponent();
void textInput(const std::string& text, const bool pasting = false) override; void textInput(const std::string& text, const bool pasting = false) override;
bool input(InputConfig* config, Input input) override; bool input(InputConfig* config, Input input) override;