SDL_STARTTEXTINPUTWITHPROPERTIES(3)

πŸ’– SDL_StartTextInputWithProperties(3) πŸ’–

okay bestie, gather round, because this one is the manual page for SDL_StartTextInputWithProperties(3) and it's genuinely so useful. it lives in the SDL3 functions family and it's about to make your window accept actual human typing. let's go πŸ’…


✨ NAME ✨

SDL_StartTextInputWithProperties β€” start accepting Unicode text input events in a window, with properties describing the input.

like. it turns on the typing. but make it customized. πŸŽ€


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_keyboard.h>

bool SDL_StartTextInputWithProperties(SDL_Window *window, SDL_PropertiesID props);

πŸ¦‹ DESCRIPTION πŸ¦‹

so this function will enable text input β€” that's SDL_EVENT_TEXT_INPUT and SDL_EVENT_TEXT_EDITING events β€” in the window you point at. and PLEASE, bestie, use this paired with SDL_StopTextInput(). they're a set. a duo. you don't take one without the other, it's giving matching friendship bracelets. 🫢

important: text input events are not received by default. so if you're sitting there like "why is nothing happening 😭" β€” that's why. you gotta call this.

also, 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. lowkey a side effect, but a real one, so know about it. πŸ’€

these are the supported properties:

  • SDL_PROP_TEXTINPUT_TYPE_NUMBER β€” an SDL_TextInputType value that describes the text being input. defaults to SDL_TEXTINPUT_TYPE_TEXT.
  • SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER β€” an SDL_Capitalization value that describes how text should be capitalized. defaults to SDL_CAPITALIZE_SENTENCES for normal text entry, SDL_CAPITALIZE_WORDS for SDL_TEXTINPUT_TYPE_TEXT_NAME, and SDL_CAPITALIZE_NONE for e-mail addresses, usernames, and passwords. (yeah, it's smart about it, no cap ✨)
  • SDL_PROP_TEXTINPUT_AUTOCORRECT_BOOLEAN β€” true to enable auto completion and auto correction. defaults to true.
  • SDL_PROP_TEXTINPUT_MULTILINE_BOOLEAN β€” true if multiple lines of text are allowed. this defaults to true if SDL_HINT_RETURN_KEY_HIDES_IME is "0" or is not set, and defaults to false if SDL_HINT_RETURN_KEY_HIDES_IME is "1".

πŸ€– android girlies, this one's for you

on Android you can directly specify the input type:

like, it just overrides everything else. main character energy, honestly. πŸ‘‘


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • window β€” the window to enable text input. (yes, the window. the one you want the typing to happen in πŸ’–)
  • props β€” the properties to use. (all those cute little properties from above 🌈)

⭐ RETURN VALUE ⭐

returns true on success or false on failure. and if it fails, bestie, call SDL_GetError() for more information β€” that's where the tea is. πŸ“


🧚 THREAD SAFETY 🧚

this function should only be called on the main thread. don't be sneaky, don't try it from a worker thread, it's not that girl. πŸ™ˆ


πŸ’œ AVAILABILITY πŸ’œ

this function is available since SDL 3.2.0. vintage-ish, but make it fresh. ✨


πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page, bestie!! you ate. go forth and accept Unicode text input with properties, you absolute icon πŸ’…βœ¨

this has been brought to you by Simple Directmedia Layer β€” SDL 3.4.18 β€” mwah, love u, bye πŸ«ΆπŸ’–

πŸ“¦ where this page comes from