Add keyboardType, submitLabel, and onSubmit#63
Merged
Conversation
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.
The form-input batch for text entry:
.keyboardType(_:),.submitLabel(_:), and.onSubmit(perform:). All three are read by the field off its own modifier list, the same way.focusedalready is.Mapping
keyboardType→ ComposeKeyboardType(.decimalPad→Decimal,.numberPad→Number,.emailAddress→Email,.URL→Uri,.phonePad→Phone, else Text).UIKeyboardTypeis defined with SwiftUI's spelling so call sites port unchanged.submitLabel→ the field'sImeAction(.search→Search,.go→Go,.send→Send,.next→Next, else Done), which names the keyboard's action key.onSubmit→ a void callback wired to everyKeyboardActionshandler, so it fires whatever action key the submit label selected.The field is now
singleLine = true, which is what makes the IME show an action key rather than a newline key.Verification
swift test— 2 new tests (type/label spelling emit;onSubmitregisters a callable callback), 112 passing..decimalPadfield,dumpsys input_methodreportedinputType=0x2002—TYPE_CLASS_NUMBER | TYPE_NUMBER_FLAG_DECIMAL, i.e. the decimal pad reached the IME.submitLabel(.search)field and pressing the action key firedonSubmit, incrementing the on-screen counter to 1Scope
The common keyboard types and submit labels; exotic
UIKeyboardTypecases fall back to the text keyboard.onSubmit(of:)(the search-vs-text trigger variant) isn't modeled — this is the plainonSubmit. Note the submitted-text binding can lag by a keystroke if the lastonChangehasn't round-tripped before submit reads it — the async text-echo path, not specific to this change.