Before calling SDL_StartTextInput() SDL2 is in a default state in which characters typed at the keyboard are received in SDL_TEXTINPUT events but no Input Method Editor (or On Screen Keyboard) is displayed.
Calling SDL_StartTextInput() followed by SDL_StopTextInput() does not restore that default state, thereafter no SDL_TEXTINPUT events are received at all. How can the default state be restored without restarting the program?
Seems like the bug is that SDL is sending SDL_TEXTINPUT events beforeSDL_StartTextInput() has been called. It makes sense that calling SDL_StopTextInput() would make it stop sending SDL_TEXTINPUT events.
The docs for SDL_StartTextInput() make it sound like your app isn’t supposed to get SDL_TEXTINPUT events until after you’ve called SDL_StartTextInput():
This function will start accepting Unicode text input events in the focused
SDL window, and start emitting SDL_TextInputEvent (SDL_TEXTINPUT) and
SDL_TextEditingEvent (SDL_TEXTEDITING) events. Please use this function in
pair with SDL_StopTextInput().
edit: the docs for SDL_StopTextInput() confirm that no longer receiving SDL_TEXTINPUT events after calling it is the intended behavior:
It’s been documented informally, anyway. For example here Sam says of SDL_StartTextInput() and SDL_StopTextInput(): “If you just want American and Western European language support on desktop systems, you can ignore those functions. They’re for more advanced international input with IMEs and mobile devices.”.
So it’s clear that SDL_TEXTINPUT events are supposed to occur before SDL_StartTextInput() is called.