lagrange icon indicating copy to clipboard operation
lagrange copied to clipboard

IME at wrong position

Open H-M-H opened this issue 4 years ago • 3 comments

In order to type Chinese or Japanese text an Input Method Editor (IME) is required. It looks like SDL already does most of the heavy lifting and provides said editor. But as lagrange does not provide SDL with information where to open the IME, the position is incorrect, see the attached screenshot: ime_off

It looks like SDL_SetTextInputRect can be used to set the correct position.

H-M-H avatar Aug 27 '21 22:08 H-M-H

I added the calls to SDL_SetTextInputRect (abe38195588660abc717f13454d8dd28e425fd9). Let's see if that helps.

skyjake avatar Aug 29 '21 04:08 skyjake

That does help! It is not quite perfect yet, for example here the position is still off: ime_off_a_little and the IME should be placed under the cursor not the input field: ime_cursor_off

And one more thing: Typically you can either let the IME handle all text editing (rendering a little text field with a cursor in a separate window) or do it yourself and the IME only displays possible candidates to select (SDL's default), in which case SDL_TextEditingEvents have to be handled.

It looks like this can be used to let the IME handle text editing, which is most likely easier than handling new events:

SDL_SetHint(SDL_HINT_IME_INTERNAL_EDITING, "1");

H-M-H avatar Aug 29 '21 10:08 H-M-H

See comment: https://github.com/skyjake/lagrange/issues/417#issuecomment-985511677

skyjake avatar Dec 03 '21 13:12 skyjake