mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Added workaround for weird SDL behavior that causes SDL to report text
input as active when app starts until first actual text input
This commit is contained in:
@@ -21,6 +21,13 @@
|
|||||||
|
|
||||||
#include <SDL_events.h>
|
#include <SDL_events.h>
|
||||||
|
|
||||||
|
InputSourceText::InputSourceText()
|
||||||
|
{
|
||||||
|
// For whatever reason, in SDL text input is considered to be active by default at least on desktop platforms
|
||||||
|
// Apparently fixed in SDL3, but until then we need a workaround
|
||||||
|
SDL_StopTextInput();
|
||||||
|
}
|
||||||
|
|
||||||
void InputSourceText::handleEventTextInput(const SDL_TextInputEvent & text)
|
void InputSourceText::handleEventTextInput(const SDL_TextInputEvent & text)
|
||||||
{
|
{
|
||||||
GH.events().dispatchTextInput(text.text);
|
GH.events().dispatchTextInput(text.text);
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ struct SDL_TextInputEvent;
|
|||||||
class InputSourceText
|
class InputSourceText
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
InputSourceText();
|
||||||
|
|
||||||
void handleEventTextInput(const SDL_TextInputEvent & current);
|
void handleEventTextInput(const SDL_TextInputEvent & current);
|
||||||
void handleEventTextEditing(const SDL_TextEditingEvent & current);
|
void handleEventTextEditing(const SDL_TextEditingEvent & current);
|
||||||
|
|
||||||
|
|||||||
@@ -72,11 +72,11 @@ void CGuiHandler::init()
|
|||||||
{
|
{
|
||||||
inGuiThread = true;
|
inGuiThread = true;
|
||||||
|
|
||||||
inputHandlerInstance = std::make_unique<InputHandler>();
|
|
||||||
eventDispatcherInstance = std::make_unique<EventDispatcher>();
|
eventDispatcherInstance = std::make_unique<EventDispatcher>();
|
||||||
windowHandlerInstance = std::make_unique<WindowHandler>();
|
windowHandlerInstance = std::make_unique<WindowHandler>();
|
||||||
screenHandlerInstance = std::make_unique<ScreenHandler>();
|
screenHandlerInstance = std::make_unique<ScreenHandler>();
|
||||||
renderHandlerInstance = std::make_unique<RenderHandler>();
|
renderHandlerInstance = std::make_unique<RenderHandler>();
|
||||||
|
inputHandlerInstance = std::make_unique<InputHandler>(); // Must be after windowHandlerInstance
|
||||||
shortcutsHandlerInstance = std::make_unique<ShortcutHandler>();
|
shortcutsHandlerInstance = std::make_unique<ShortcutHandler>();
|
||||||
framerateManagerInstance = std::make_unique<FramerateManager>(settings["video"]["targetfps"].Integer());
|
framerateManagerInstance = std::make_unique<FramerateManager>(settings["video"]["targetfps"].Integer());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user