1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 09:39:43 +01:00

Add buffer for IME editing events

When inputting uncommitted text from an IME, this is now stored in a
std::string imebuffer, just like keybuffer. It also enables extended
editing events, so text longer than what fits in the standard editing
event is also supported. This commit does not yet display the text
onscreen.
This commit is contained in:
Dav999 2024-08-01 19:18:20 +02:00 committed by Misa Elizabeth Kai
parent 345eca5e10
commit a9ca63b367
3 changed files with 14 additions and 2 deletions

View file

@ -51,6 +51,7 @@ KeyPoll::KeyPoll(void)
sensitivity = 2;
keybuffer = "";
imebuffer = "";
leftbutton=0; rightbutton=0; middlebutton=0;
mousex = 0;
mousey = 0;
@ -65,12 +66,14 @@ KeyPoll::KeyPoll(void)
void KeyPoll::enabletextentry(void)
{
keybuffer = "";
imebuffer = "";
SDL_StartTextInput();
}
void KeyPoll::disabletextentry(void)
{
SDL_StopTextInput();
imebuffer = "";
}
bool KeyPoll::textentry(void)
@ -321,6 +324,13 @@ void KeyPoll::Poll(void)
keybuffer += evt.text.text;
}
break;
case SDL_TEXTEDITING:
imebuffer = evt.edit.text;
break;
case SDL_TEXTEDITING_EXT:
imebuffer = evt.editExt.text;
SDL_free(evt.editExt.text);
break;
/* Mouse Input */
case SDL_MOUSEMOTION:

View file

@ -69,6 +69,7 @@ public:
bool textentry(void);
bool pressedbackspace;
std::string keybuffer;
std::string imebuffer;
bool linealreadyemptykludge;

View file

@ -599,6 +599,7 @@ int main(int argc, char *argv[])
}
SDL_SetHintWithPriority(SDL_HINT_IME_SHOW_UI, "1", SDL_HINT_OVERRIDE);
SDL_SetHintWithPriority(SDL_HINT_IME_SUPPORT_EXTENDED_TEXT, "1", SDL_HINT_OVERRIDE);
/* We already do the button swapping in ButtonGlyphs, disable SDL's swapping */
SDL_SetHintWithPriority(SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS, "0", SDL_HINT_OVERRIDE);