openfl / lime

A foundational Haxe framework for cross-platform development
https://lime.openfl.org/
MIT License
749 stars 359 forks source link

TextField IME candidate list pane invisible on Windows #1766

Open tabris17 opened 4 months ago

tabris17 commented 4 months ago

target is windows native

The cause of this issue is that the SDL version is too old.

openfl/libsdl/blob/master/src/video/windows/SDL_windowskeyboard.c

videodata->ime_uiless = UILess_SetupSinks(videodata);

This line of code causes the IME candidate pane to not be rendered. and this issue has been fixed in the latest version of SDL:

libsdl-org/SDL/blob/main/src/video/windows/SDL_windowskeyboard.c

if (WIN_ShouldShowNativeUI()) {
    videodata->ime_uiless = SDL_FALSE;
} else {
    videodata->ime_uiless = UILess_SetupSinks(videodata);
}
player-03 commented 4 months ago

See #1684 for the work that's been done on this, though it does seem to have stalled.

tabris17 commented 4 months ago

Is it possible to fix openfl/libsdl with temporary patch?

The code below works fine on my windows system:

#if defined(__WIN32__)
videodata->ime_uiless = SDL_FALSE;
#else
videodata->ime_uiless = UILess_SetupSinks(videodata);
#endif
player-03 commented 4 months ago

Sure, submit a PR.

joshtynjala commented 4 months ago

It is probably worth mentioning that the 8.2.0-Dev branch switched from openfl/libsdl to libsdl-org/SDL. Any further changes that we make to openfl/libsdl will be lost with the Lime 8.2 update.

joshtynjala commented 4 months ago

However, I see that support for the Windows IME window was added in commit libsdl-org/SDL@6f972052296fdfe63ecaa7edab3e5b4e663eea06. I see that's part of SDL's release-2.0.18 tag. The 8.2.0-Dev branch appears to be on release-2.30.0, so this fix will be included in Lime 8.2 already.

player-03 commented 4 months ago

Oh whoops, I got the dates wrong. I thought 8.2.0-Dev didn't have the fix, so I didn't mention it.

tabris17 commented 4 months ago

I have tried 8.2.0-Dev branch and found that SDL_HINT_IME_SHOW_UI is not enable by default.

The following code needs to be added to the SDLWindow::SDLWindow() function to display the IME candidate list:

#if defined (HX_WINDOWS)
SDL_SetHint (SDL_HINT_IME_SHOW_UI, "1");
#endif
player-03 commented 4 months ago

That feels like something most users won't need.

But SDL_SetHint() is declared extern; I wonder if that means you can get at it using CFFI? Then you'd be able to set whatever hints you needed. Sadly I don't know enough about CFFI to say for sure.