Back to Uno

TextBox

doc/articles/controls/TextBox.md

6.6-release-branch-cut14.2 KB
Original Source

TextBox

InputScopes Mapping Table

ValueDescriptionAndroidiOS
AlphanumericFullWidthInput scope is intended for alphanumeric full-width characters.
AlphanumericHalfWidthInput scope is intended for alphanumeric half-width characters.
AlphanumericPinExpected input is an alphanumeric PIN.
ChatInput scope is intended for chat strings.
ChatWithoutEmojiExpected input does not include emoji. Advises input processors to not show the emoji key.
ChineseFullWidthInput scope is intended for Chinese full-width characters.
ChineseHalfWidthInput scope is intended for Chinese half-width characters.
CurrencyAmountInput scope is intended for working with a currency amount (no currency symbol).InputTypes.ClassNumber OR InputTypes.NumberFlagDecimalUIKeyboardType.DecimalPad
CurrencyAmountAndSymbolInput scope is intended for working with amount and symbol of currency.
DateDayNumberInput scope is intended for working with a numeric day of the month.
DateMonthNumberInput scope is intended for working with a numeric month of the year.
DateYearInput scope is intended for working with a numeric year.
DefaultNo input scope is applied.InputTypes.ClassTextUIKeyboardType.Default
DigitsInput scope is intended for working with a collection of numbers.
EmailNameOrAddressInput scope is intended for working with an email name or full email address.InputTypes.ClassText OR InputTypes.TextVariationEmailAddressUIKeyboardType.EmailAddress
EmailSmtpAddressInput scope is intended for working with a Simple Mail Transport Protocol (SMTP) form e-mail address (accountname@host).InputTypes.ClassText OR InputTypes.TextVariationEmailAddressUIKeyboardType.EmailAddress
FormulaInput scope is intended for spreadsheet formula strings.
FormulaNumberExpected input is a mathematical formula. Advises input processors to show the number page.
HangulFullWidthInput scope is intended for Hangul full-width characters.
HangulHalfWidthInput scope is intended for Hangul half-width characters.
HanjaInput scope is intended for Hanja characters.
HiraganaInput scope is intended for Hiragana characters.
KatakanaFullWidthInput scope is intended for Katakana full-width characters.
KatakanaHalfWidthInput scope is intended for Katakana half-width characters.
MapsInput scope is intended for working with a map location.
NameOrPhoneNumberInput scope is intended for working with a name or telephone number.
NativeScriptInput scope is intended for native script.
NumberInput scope is intended for working with digits 0-9.InputTypes.ClassNumberUIKeyboardType.NumberPad
NumberFullWidthInput scope is intended for full-width number characters.InputTypes.ClassPhone(*)UIKeyboardType.NumbersAndPunctuation
NumericPasswordExpected input is a numeric password, or PIN.
NumericPinExpected input is a numeric PIN.InputTypes.ClassNumberUIKeyboardType.NumbersAndPunctuation
PasswordInput scope is intended for working with an alphanumeric password, including other symbols, such as punctuation and mathematical symbols.
PersonalFullNameInput scope is intended for working with a complete personal name.
SearchInput scope is intended for search strings.InputTypes.ClassTextUIKeyboardType.Default
SearchIncrementalInput scope is intended for search boxes where incremental results are displayed as the user types.
TelephoneAreaCodeInput scope is intended for working with a numeric telephone area code.
TelephoneCountryCodeInput scope is intended for working with a numeric telephone country code.
TelephoneLocalNumberInput scope is intended for working with a local telephone number.
TelephoneNumberInput scope is intended for working with telephone numbers.InputTypes.ClassPhoneUIKeyboardType.PhonePad
TextInput scope is intended for working with text.
TimeHourInput scope is intended for working with a numeric hour of the day.
TimeMinutesOrSecondsInput scope is intended for working with a numeric minute of the hour, or second of the minute.
UrlIndicates a Uniform Resource Identifier (URI). This can include URL, File, or File Transfer Protocol (FTP) formats.InputTypes.ClassText OR InputTypes.TextVariationUriUIKeyboardType.Url

[*: Workaround]

Controlling the Keyboard on iOS

If a view needs to keep the keyboard opened when tapping on it, use the Uno.UI.Controls.Window.SetNeedsKeyboard attached property.

Paste event

Support for capturing and handling the Paste event is implemented on all targets except for macOS.

In the case of Android, it is currently limited to the pastes that are triggered by the native context menu (e.g. after long-pressing the TextBox). It cannot detect paste triggered by the virtual keyboard or via a hardware keyboard shortcut.

Pointer capture on WebAssembly

In addition to focus, TextBox control also captures pointers, so that manipulations like scrolling through contents are possible. However, on WASM setting the programmatic capture will prevent the native scrolling behavior of the underlying <input>. For that reason, we avoid performing the pointer capture in this case. If you still want to capture the pointer, you can do so by setting the IsPointerCaptureRequired attached property to true:

In C#:

csharp
#if __WASM__
myTextBox.IsPointerCaptureRequired = true;
#endif

Or in XAML:

xml
<TextBox wasm:IsPointerCaptureRequired="True" />

Follow Platform-specific XAML guide to add the wasm namespace.

The value only affects WebAssembly, all other targets capture by default.

Customizing the Enter key appearance

On mobile targets you can customize the visual appearance of the Enter key on the virtual keyboard. This can be done using the TextBoxExtensions.InputReturnType attached property:

csharp
Uno.UI.Xaml.Controls.TextBoxExtensions.SetInputReturnType(myTextBox, Uno.UI.Xaml.Controls.InputReturnType.Search);

These are the supported input return type values:

  • Enter: Typically indicating inserting a new line.
  • Done: There is nothing more to input, and the input method editor (IME) will be closed.
  • Go: Typically meaning to take the user to the target of the text they typed.
  • Next: Typically taking the user to the next field that will accept text.
  • Previous: Typically taking the user to the previous field that will accept text.
  • Search: Typically taking the user to the results of searching for the text they have typed.
  • Send: Typically delivering the text to its target.
  • Default: System default.