forked from Mirrorlandia_minetest/irrlicht
SDL: Improve handling of IMEs (#285)
* Set text input rectangle for IMEs * Avoid unnecessarily "restarting" text input
This commit is contained in:
parent
f1504093d1
commit
6779ac83f9
@ -218,9 +218,28 @@ int CIrrDeviceSDL::findCharToPassToIrrlicht(int assumedChar, EKEY_CODE key) {
|
|||||||
void CIrrDeviceSDL::resetReceiveTextInputEvents() {
|
void CIrrDeviceSDL::resetReceiveTextInputEvents() {
|
||||||
gui::IGUIElement *elem = GUIEnvironment->getFocus();
|
gui::IGUIElement *elem = GUIEnvironment->getFocus();
|
||||||
if (elem && elem->acceptsIME())
|
if (elem && elem->acceptsIME())
|
||||||
SDL_StartTextInput();
|
{
|
||||||
|
// IBus seems to have an issue where dead keys and compose keys do not
|
||||||
|
// work (specifically, the individual characters in the sequence are
|
||||||
|
// sent as text input events instead of the result) when
|
||||||
|
// SDL_StartTextInput() is called on the same input box.
|
||||||
|
core::rect<s32> pos = elem->getAbsolutePosition();
|
||||||
|
if (!SDL_IsTextInputActive() || lastElemPos != pos)
|
||||||
|
{
|
||||||
|
lastElemPos = pos;
|
||||||
|
SDL_Rect rect;
|
||||||
|
rect.x = pos.UpperLeftCorner.X;
|
||||||
|
rect.y = pos.UpperLeftCorner.Y;
|
||||||
|
rect.w = pos.getWidth();
|
||||||
|
rect.h = pos.getHeight();
|
||||||
|
SDL_SetTextInputRect(&rect);
|
||||||
|
SDL_StartTextInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
SDL_StopTextInput();
|
SDL_StopTextInput();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! constructor
|
//! constructor
|
||||||
|
@ -303,6 +303,8 @@ namespace irr
|
|||||||
|
|
||||||
bool Resizable;
|
bool Resizable;
|
||||||
|
|
||||||
|
core::rect<s32> lastElemPos;
|
||||||
|
|
||||||
struct SKeyMap
|
struct SKeyMap
|
||||||
{
|
{
|
||||||
SKeyMap() {}
|
SKeyMap() {}
|
||||||
|
Loading…
Reference in New Issue
Block a user