Confused on how to handle (or why) SDL_StartTextInput()?

OK, so, you agree that Jiang’s reply of getting SDL_TEXTEDITING events for everything is just wrong, and that is ONLY useful for certain languages in some undescribed way. Forum post: SDL :: View topic - Confused on how to handle (or why) SDL_StartTextInput() ?

I think Jian’s post assumes that you are using an IME, but most people
aren’t, which is why it might be misleading.

SDL_TEXTEDITING gets fired always on windows(?) even when SDL_StartTextInput() is not called (see forum post SDL :: View topic - Is it normal to get SDL_TEXTEDITING events w/o SDL_StartText), and still doesn’t contain any useful information.

I’m not sure why that would be the case. If the event has 0 length and
you’re not using IME stuff, then I think it can be safely ignored.

SDL_TEXTINPUT is the one one that should always fire when a person types any key, and should also contain utf8 encoded translation of that key if needed, but, it does not handle hitting backspace to delete the last character as was described in that post.
That means, that people handling SDL_TEXTINPUT must write their own routine, and check if it is a multibyte sequence or not if a user presses backspace, and want to delete the last character(s).

Yes, I’ve had to do exactly that in my applications.

How is it possible to test exactly when SDL_TEXTEDITING contains actually useful information for something, since, AFAIK, SDL_TEXTINPUT will always contain the correct character be it “normal” or multibyte.

In the Linux code, the length parameter of SDL_TEXTEDITING events can be
used to see if it contains text. If it’s non-zero then you can display
the text in some way which shows it’s in the process of being composed
(Most non-SDL programs seem to underline this kind of text.)

I have yet to see any full example of how SDL_TEXTEDITING can be used for anything.
The wiki page for this is https://wiki.libsdl.org/SDL_TextEditingEvent and it shows it is in dire need of more explanation when & how to handle this event.

Yes, the wiki page could definitely use some work. It does link to
https://wiki.libsdl.org/Tutorials/TextInput though, which has a
reasonable explanation of the system.

Basically, you should only need to look at SDL_TEXTEDITING events if you
want to render the currently-being-editing text used in IMEs.

There’s a hint “SDL_IME_INTERNAL_EDITING” also, which allows you to just
ignore the EDITING events entirely and let the OS do the rendering of
this type of text if an IME is in use (It will just give you a TEXTINPUT
when the user finishes composing). But I think it’s only implemented for
the Linux code.On 27/02/15 21:54, Sparks wrote: