diff --git a/src/gui/interface/Engine.cpp b/src/gui/interface/Engine.cpp index 57b27900e..e9adf3834 100644 --- a/src/gui/interface/Engine.cpp +++ b/src/gui/interface/Engine.cpp @@ -249,10 +249,15 @@ void Engine::onTextEditing(String text, int start) // arrives. We also forward a textediting event on every packet, // which is redundant, but should be okay, as textediting events are // not supposed to have an effect on the actual text being edited. - if (start == 0) + // * We define a first-y looking packet as one with a start parameter + // lower than or equal to the start parameter of the previous packet. + // This is general enough that it seems to work around the bugs + // of all SDL input method backends. + if (start <= lastTextEditingStart) { textEditingBuf.clear(); } + lastTextEditingStart = start; textEditingBuf.append(text); if (state_ && !ignoreEvents) state_->DoTextEditing(textEditingBuf); diff --git a/src/gui/interface/Engine.h b/src/gui/interface/Engine.h index 3e8bbe69d..1eaba3ac5 100644 --- a/src/gui/interface/Engine.h +++ b/src/gui/interface/Engine.h @@ -5,6 +5,7 @@ #include "common/ExplicitSingleton.h" #include "graphics/Pixel.h" #include "gui/interface/Point.h" +#include class Graphics; namespace ui @@ -92,6 +93,7 @@ namespace ui bool resizable; bool textInput = false; + int lastTextEditingStart = INT_MAX; float dt; float fps;