TextBox
Definition
Users enter text in a text box component.
The initial or user-entered text value in a text box component is in the Text
property. If Text
is blank, you can use the H
i
nt
property to provide the user with a suggestion of what to type. The Hint
appears as faint text in the box.
The MultiLine
property determines if the text can have more than one line. For a single line text box, the keyboard will close automatically when the user presses the Done key. To close the keyboard for multiline text boxes, the app should use the HideKeyboard
method or rely on the user to press the Back key.
The NumbersOnly
property restricts the keyboard to accept numeric input only.
Other properties affect the appearance of the text box (TextAlignment
, BackgroundColor
, etc.) and whether it can be used (Enabled
).
Text boxes are usually used with the Button
component, with the user clicking on the Button
when text entry is complete.
If the text entered by the user should not be displayed, use PasswordTextBox
instead.
Properties
- BackgroundColor
- The background color of the
TextBox
`. You can choose a color by name in the Designer or in the Blocks Editor. The default background color is ‘default’ (shaded 3-D look). - Enabled
- If set, user can enter text into the
TextBox
. - FontBold
- Specifies whether the text of the
TextBox
should be bold. Some fonts do not support bold. - FontItalic
- Specifies whether the text of the
TextBox
should be italic. Some fonts do not support italic. - FontSize
- Specifies the text font size of the
TextBox
, measured in sp(scale-independent pixels). - FontTypeface
- The text font face of the
TextBox
. Valid values are0
(default),1
(serif),2
(sans serif), or3
(monospace). - Height
- Specifies the
TextBox
’s vertical height, measured in pixels. - HeightPercent
- Specifies the
TextBox
’s vertical height as a percentage of theScreen
’sHeight
. - Hint
TextBox
hint for the user.- MultiLine
- If true, then this
TextBox
accepts multiple lines of input, which are entered using the return key. For single line text boxes there is a Done key instead of a return key, and pressing Done hides the keyboard. The app should call the HideKeyboard method to hide the keyboard for a mutiline text box. - NumbersOnly
- If true, then this
TextBox
accepts only numbers as keyboard input. Numbers can include a decimal point and an optional leading minus sign. This applies to keyboard input only. Even if
NumbersOnlyis true, you can set the text to anything at all using the [
Text`](#TextBox.Text) property. - ReadOnly
- Whether the TextBox is read-only. By default, this is
true
. - Text
- The text in the
TextBox
, which can be set by the programmer in the Designer or Blocks Editor, or it can be entered by the user (unless theEnabled
property is false). - TextAlignment
- Specifies the alignment of the
TextBox
’s text. Valid values are:0
(normal; e.g., left-justified if text is written left to right),1
(center), or2
(opposite; e.g., right-justified if text is written left to right). - TextColor
- Specifies the text color of the
TextBox
as an alpha-red-green-blue integer. - Visible
- Specifies whether the
TextBox
should be visible on the screen. Value istrue
if theTextBox
is showing andfalse
if hidden. - Width
- Specifies the horizontal width of the
TextBox
, measured in pixels. - WidthPercent
- Specifies the horizontal width of the
TextBox
as a percentage of theScreen
’sWidth
.