feat(keyboard): add text input properties and get text input area - #436
Open
ozongzi wants to merge 1 commit into
Open
feat(keyboard): add text input properties and get text input area#436ozongzi wants to merge 1 commit into
ozongzi wants to merge 1 commit into
Conversation
Add wrappers for: - SDL_StartTextInputWithProperties (as TextInputUtil::start_with_options) - SDL_GetTextInputArea (as TextInputUtil::rect) - SDL_TextInputType, SDL_Capitalization and the five SDL_PROP_TEXTINPUT_* properties, exposed as TextInputType, Capitalization and TextInputOptions Without these, a text field cannot tell the platform what is being entered, so on-screen keyboards cannot be specialized for e-mail, username or number input, and password fields cannot turn off the input method editor. Every field of TextInputOptions is an Option so that leaving one unset keeps SDL's own default, which for capitalization depends on the input type.
Copilot stopped reviewing on behalf of
ozongzi due to an error
August 17, 2026 15:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add wrappers for the text input APIs that were still missing:
SDL_StartTextInputWithProperties→TextInputUtil::start_with_optionsSDL_GetTextInputArea→TextInputUtil::rect(the missing half ofset_rect)SDL_TextInputType→TextInputTypeSDL_Capitalization→CapitalizationSDL_PROP_TEXTINPUT_*properties →TextInputOptionsWithout these, a text field cannot tell the platform what is being entered, so on-screen keyboards cannot be specialized for e-mail, username or number input, and password fields cannot turn off the input method editor.
Notes on the design
TEXT_prefix, sinceTextInputType::already qualifies them:Email,Username,PasswordHidden.TextInputOptionsis anOption, andNoneleaves the property unset so SDL applies its own default. This matters because the default capitalization depends on the input type (sentences for text, words for names, none for e-mail and usernames), so a plain non-optional field would have to guess a default and would override SDL's.android_input_typeis present on all platforms rather than#[cfg(target_os = "android")], so cross-platform code can construct the struct withoutcfg. It is documented as Android-only and SDL ignores the property elsewhere.sys::propertiesdirectly rather than thePropertieswrapper, which has no plain number/boolean setters and would leakPropertiesErrorinto this API. The group is destroyed right after the call.start()is untouched. It discards theboolfromSDL_StartTextInput, but changing that is a breaking change and does not belong here.Testing
cargo build,cargo fmt --checkandcargo clippy --all-targetsare clean for the touched filecargo test --doc keyboardpasses, including the two new examplesstart_with_optionsreports active,set_rect/rectround-trip the rectangle and cursor offset,Default::default()works, andstopdeactivates