Skip to content

Native Input API Improvements and Fixes - #7821

Open
Berstanio wants to merge 35 commits into
libgdx:masterfrom
Berstanio:feat/native-input-improvements
Open

Berstanio wants to merge 35 commits into
libgdx:masterfrom
Berstanio:feat/native-input-improvements

Conversation

@Berstanio

@Berstanio Berstanio commented Jun 14, 2026 •

Copy link
Copy Markdown
Contributor

The PR is based on #7815. It fixes multiple issues and incompatibilities, cleans up legacy code design (especially on iOS) and adds a ton of new configuration option.
The PR is best tested over the NativeInputTest class.
The PR fixes #7812.

New NativeInputConfiguration options

  • Write Mode: setWriteMode(WriteMode) on NativeInputConfiguration controls how often the in-progress text is mirrored back into the app via TextInputWrapper.writeResults while a native field is open:
    • ONLY_FINAL (default): written once, on close (the previous behavior).
    • TEXT_UPDATES: also on every text change as the IME assembles text; the payload carries the current text plus caret/selection, so the caret is tracked per keystroke.
    • ALL_UPDATES: like TEXT_UPDATES, but also fires on selection/caret-only changes (tap-to-move-caret, drag-select). Not fully functional on iOS < 13.
  • Field insets: setHorizontalInsetFraction(float) insets the field from each screen edge. Looks a bit cleaner then edge-to-edge
  • Rounded corners: setCornerRadius(float) rounds the TextField corners. Looks better, esp. on iOS
  • Text margin: setTextMargin(float) horizontal padding between the field edge and its text.
  • Colors: setBackgroundColor / setTextColor / setPlaceholderColor.
  • Return key: setReturnKeyType(ReturnKeyType) (GO/SEARCH/SEND/NEXT/DONE). Allows for visual hints what will happen when submitting the input.
  • Autofill: setContentType(ContentType) (USERNAME/PASSWORD/NEW_PASSWORD/ONE_TIME_CODE/EMAIL/PHONE). Enables password-manager and OTP autofill.
  • Autocapitalization: setAutocapitalization(Autocapitalization) (NONE/WORDS/SENTENCES/CHARACTERS). Allows to independently configure autocapitilization rules.
  • Autocomplete threshold: setAutoCompleteThreshold(int) minimum typed characters before suggestions appear.
  • Customizer hook: setFieldCustomizer(NativeInputFieldCustomizer), a new public interface for platform-specific tweaks beyond the config (cast the passed object to IOSNativeInput / AndroidNativeInput). Intended for every customization that is not covered yet.

Other changes:

  • Built-in validators on Input.InputStringValidator: DIGITAL_VALIDATOR and PHONE_VALIDATOR.
  • Better validation: NativeInputConfiguration.validate() now reports all problems at once and additionally checks the current text and every autocomplete entry against the configured validator.

Default appearance change

  • The native field now renders inset 5% per side with rounded corners by default (previously edge-to-edge). Restore the old look with setHorizontalInsetFraction(0) and setCornerRadius(0).

iOS / Android fixes

  • iOS 26 input-accessory ("Done" pill / liquid-glass) positioning fixed, including the iPad floating keyboard.
  • Hardware keyboard on iOS now work properly.
  • Better hardware support on android (full compatibility deemed impossible due to missing API's)
  • Proper support for iPad floating keyboards.
  • Numpad/Phonepad keyboard types now promote to a full keyboard on iPad (they didn't work properly otherwise).
  • Multiple autocomplete fixes: proper multiline (UITextView) placeholder, correct positioning, correct handling of the iPad keyboard close button.

Internals & tests

  • The iOS and (to a lesser extent) Android native-input backends were restructured where needed to support the above.
  • NativeInputTest undergone a significant rewrite to make it easier to use. Heavily assisted by generative AI.

Berstanio and others added 30 commits June 4, 2026 15:46
…OnscreenKeyboard` respect the OnscreenKeyboardType
…ntentType, capitalization, cornerRadius to native input config. Also implement UITextView placeholder properly
@Berstanio
Berstanio force-pushed the feat/native-input-improvements branch from 4b7c81e to c763d12 Compare June 14, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

input Concerning Gdx.input

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NativeOnscreenKeyboard behaves different to default, needs more configurability

3 participants