Work around some input method bug on windows

At least this fixes Hangul input for me. I'm sure nobody else had any problems with it and I'm sure everyone will start having problems with it now :)
This commit is contained in:
Tamás Bálint Misius 2023-08-01 18:41:34 +02:00
parent a5e179e530
commit 2c56adde5a
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2
2 changed files with 8 additions and 1 deletions

View File

@ -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);

View File

@ -5,6 +5,7 @@
#include "common/ExplicitSingleton.h"
#include "graphics/Pixel.h"
#include "gui/interface/Point.h"
#include <climits>
class Graphics;
namespace ui
@ -92,6 +93,7 @@ namespace ui
bool resizable;
bool textInput = false;
int lastTextEditingStart = INT_MAX;
float dt;
float fps;