From be2b7613562cec383875fa854ab9b1f76b85cdc1 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Thu, 20 Jul 2023 16:03:59 +0200 Subject: [PATCH] Fixed an issue where SDL_StartTextInput() was sometimes set when not actually inputting any text --- es-core/src/InputManager.cpp | 1 + es-core/src/components/TextEditComponent.cpp | 6 ++++++ es-core/src/components/TextEditComponent.h | 1 + 3 files changed, 8 insertions(+) diff --git a/es-core/src/InputManager.cpp b/es-core/src/InputManager.cpp index d232c7815..299e792ca 100644 --- a/es-core/src/InputManager.cpp +++ b/es-core/src/InputManager.cpp @@ -59,6 +59,7 @@ void InputManager::init() SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER); SDL_GameControllerEventState(SDL_ENABLE); + SDL_StopTextInput(); if (!Utils::FileSystem::exists(getConfigPath())) { LOG(LogInfo) << "No input configuration file found, default mappings will be applied"; diff --git a/es-core/src/components/TextEditComponent.cpp b/es-core/src/components/TextEditComponent.cpp index 009bb2931..658864c81 100644 --- a/es-core/src/components/TextEditComponent.cpp +++ b/es-core/src/components/TextEditComponent.cpp @@ -37,6 +37,12 @@ TextEditComponent::TextEditComponent() setSize(4096, mFont->getHeight() + (TEXT_PADDING_VERT * mRenderer->getScreenHeightModifier())); } +TextEditComponent::~TextEditComponent() +{ + // Always disable text input when destroying this component. + SDL_StopTextInput(); +} + void TextEditComponent::onFocusGained() { mFocused = true; diff --git a/es-core/src/components/TextEditComponent.h b/es-core/src/components/TextEditComponent.h index f6daf22c6..a9e35fa06 100644 --- a/es-core/src/components/TextEditComponent.h +++ b/es-core/src/components/TextEditComponent.h @@ -21,6 +21,7 @@ class TextEditComponent : public GuiComponent { public: TextEditComponent(); + ~TextEditComponent(); void textInput(const std::string& text, const bool pasting = false) override; bool input(InputConfig* config, Input input) override;