SDL_StartTextInput(3)

πŸ’– SDL_StartTextInput(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the man pages, where we learn how to make a window actually listen to your typing πŸŽ€


✨ NAME ✨

SDL_StartTextInput β€” start accepting Unicode text input events in a window. periodt. πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_keyboard.h>

bool SDL_StartTextInput(SDL_Window *window);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the tea β˜• β€” this function will enable text input (that's SDL_EVENT_TEXT_INPUT and SDL_EVENT_TEXT_EDITING events, no cap) in the window you point at. the way it works is you use this one paired with SDL_StopTextInput(), like the iconic duo they are 🫢

and listen β€” text input events are not received by default. like, at all. zero. nada. you gotta ask for them, bestie. πŸ™ˆ

also heads up, on some platforms using this function shows the screen keyboard and/or activates an IME, which can prevent some key press events from being passed through. so like, some keys might just get ghosted πŸ’€ not by you, by the platform. iykyk.


πŸ‘‘ FUNCTION PARAMETERS πŸ‘‘

  • window β€” the window to enable text input. that's it, that's the whole list, she's simple and she's iconic 🌈

⭐ RETURN VALUE ⭐

Returns true on success or false on failure πŸŽ€ and if it fails, you call SDL_GetError() for more information β€” like, go get the receipts, she'll tell you what went wrong.


πŸ’œ THREAD SAFETY πŸ’œ

this function should only be called on the main thread. no side quests, no extra threads, main character energy only πŸ‘‘


✨ AVAILABILITY ✨

this function is available since SDL 3.2.0. she's new-ish, she's fresh, she ate πŸ“


🌈 SEE ALSO 🌈


ok that's the whole page bestie, go forth and enable some text input πŸ’–

and that's a wrap on this little Simple Directmedia Layer moment, brought to you by SDL 3.4.18 ✨ thanks for reading, ily, mwah πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from