Haven’t had a lot of interest in this topic in my other posts on the topic of IME support, so I figured I’d make it a lot easier for folks. I’ve put a small, simple single-file test program for IME support over here:
There’s even a cmake project file for it in there, if that’s your jam (but honestly, it’s a single c file that’s 50 lines long including blank lines and comments, so just compile it however you like).
The program creates a small 100x100 pixel SDL window which immediately goes into text entry mode, and prints out messages to stdout as it receives text entry. And it spits out text editing/input events to stdout, which is great if your console supports utf-8 encoded text. Here’s a picture of the test app running on Ubuntu/Gnome, with a Chinese keyboard layout active:
The window at the bottom is the OS’s candidate list for simplified chinese, which shows a number of different unicode completions for what I’ve been typing into the window (which was the text “pinyin”).
This also works similarly if you compile and run the program on OSX, with a chinese or japanese keyboard layout active.
On Windows, though, the candidate list doesn’t open when you start typing, making it much harder for users to enter text in CJK and similar languages which tend to use the completion list to select unicode glyphs during text entry. (it’s still functioning; it just only selects whichever composition it would be showing furthest on the left, if the list was showing)
And of course, if you modify the program to open in fullscreen instead of in a desktop window, then none of the platforms will draw the candidate list at all, as they aren’t compositing the OS’s candidate list window over whatever you’re drawing. I’m interested in people’s thoughts about:
- How to fix the candidate list not showing up in Windows, so that it behaves with the same functionality available on Linux/OSX.
- How to properly handle candidate lists when a program (typically a game) is running fullscreen.
I want to mention that this is super easy and non-scary to test on all desktop OSes I’ve tested it on, even if you don’t speak a CJK language.
Windows and Mac are especially easy; Windows gives you a pop-up for selecting your keyboard layout in the toolbar (and then gives you another toggle button for latin/ime text entry even once you’ve selected Chinese), and Mac does something similar in the top menu bar. You don’t need to change your OS’s main display language; just set your keyboard layout to Chinese, Japanese, or similar, and you can play with the IME, and they give you a simple always-onscreen menu to change it back to English or whatever you’re comfortable with. You absolutely aren’t going to get trapped in another language and be unable to figure out how to set things back to english; your OS itself remains in whatever language you prefer for the whole time.
(Linux is a bit trickier to set up to do IME entry, and at least under Ubuntu/Gnome required a frankly astonishing number of logout/login cycles throughout the setup process for me; it’s worth finding an online guide if you want to test over there, but Windows and Mac are super simple to get going)
What do people think?