[bugfix][windows] openfl textfield IME candidate pane invisible

I use haxeui-openfl backend on Windows native.
I found that textfield does not display the candidate pane when typing with IME.
After tracing, I found that the issue was caused by SDL.
We can modify the source code of SDL and rebuild lime.ndll to solve it

first, download lime source by git:

git clone --recursive https://github.com/openfl/lime

then, open project\lib\sdl\src\video\windows\SDL_windowskeyboard.c,Find the code videodata->ime_uiless = UILess_SetupSinks(videodata); and comment it

static void
IME_Init(SDL_VideoData *videodata, HWND hwnd)
{
    if (videodata->ime_initialized)
        return;

    videodata->ime_hwnd_main = hwnd;
    if (SUCCEEDED(WIN_CoInitialize())) {
        videodata->ime_com_initialized = SDL_TRUE;
        CoCreateInstance(&CLSID_TF_ThreadMgr, NULL, CLSCTX_INPROC_SERVER, &IID_ITfThreadMgr, (LPVOID *)&videodata->ime_threadmgr);
    }
    videodata->ime_initialized = SDL_TRUE;
    videodata->ime_himm32 = SDL_LoadObject("imm32.dll");
    if (!videodata->ime_himm32) {
        videodata->ime_available = SDL_FALSE;
        SDL_ClearError();
        return;
    }
    videodata->ImmLockIMC = (LPINPUTCONTEXT2 (WINAPI *)(HIMC))SDL_LoadFunction(videodata->ime_himm32, "ImmLockIMC");
    videodata->ImmUnlockIMC = (BOOL (WINAPI *)(HIMC))SDL_LoadFunction(videodata->ime_himm32, "ImmUnlockIMC");
    videodata->ImmLockIMCC = (LPVOID (WINAPI *)(HIMCC))SDL_LoadFunction(videodata->ime_himm32, "ImmLockIMCC");
    videodata->ImmUnlockIMCC = (BOOL (WINAPI *)(HIMCC))SDL_LoadFunction(videodata->ime_himm32, "ImmUnlockIMCC");

    IME_SetWindow(videodata, hwnd);
    videodata->ime_himc = ImmGetContext(hwnd);
    ImmReleaseContext(hwnd, videodata->ime_himc);
    if (!videodata->ime_himc) {
        videodata->ime_available = SDL_FALSE;
        IME_Disable(videodata, hwnd);
        return;
    }
    videodata->ime_available = SDL_TRUE;
    IME_UpdateInputLocale(videodata);
    IME_SetupAPI(videodata);
    //videodata->ime_uiless = UILess_SetupSinks(videodata);
    IME_UpdateInputLocale(videodata);
    IME_Disable(videodata, hwnd);
}

rebuild lime.ndll by command lime rebuild windows
finally, replace the original lime.ndll with the file lime\ndll\Windows64\lime.ndll

Hope this helps someone with the same trouble

Very interesting! Have you considered opening an PR in lime, or letting the lime guys know?

If it doesnt break anything else im guessing they would be happy to hear about your fix.

Cheers,
Ian

In fact, the latest version of SDL has fixed this bug

SDL_windowskeyboard.c

if (WIN_ShouldShowNativeUI()) {
    videodata->ime_uiless = SDL_FALSE;
} else {
    videodata->ime_uiless = UILess_SetupSinks(videodata);
}

I don’t know why, openfl uses an old version of SDL, which has not been updated for a long time.

1 Like

Ah, ok, well, thats good news - means if / when they update they’ll get the fix. I would still consider opening an issue (or something on their forums) since its likely they dont know that it will fix this specific thing.

Might even encourage them to update, who knows :slight_smile:

Cheers,
Ian

Good news, the issue will be fixed in version 8.2

1 Like