ztk::android::TextField
Makes a field of one line of text (EditText) with the line of the theme under it.
Synopsis
ztk::android::TextField new ?OPTION VALUE ...?
$screen add textfield ?OPTION VALUE ...?
Arguments
| Name |
Type |
Default |
Meaning |
-text |
text |
empty |
The text. cget -text gives the text that the user typed. |
-placeholder |
text |
empty |
The gray text of an empty field: its hint. TalkBack reads it. |
-secure |
boolean |
0 |
1 hides the text, for a password. |
-enabled |
boolean |
1 |
0 dims the field, and it ignores taps. |
-command |
script |
empty |
Runs at the done key of the keyboard, with the field appended. |
-changecommand |
script |
empty |
Runs at each change of the text, with the field appended. A change with configure -text runs it too. |
invoke |
method |
|
Runs the action of the done key. |
-accessory |
list |
empty |
The labels of a row of buttons over the soft keyboard, such as {Next Done}, at the right edge. An empty list shows no row. The row shows while the field has the focus, as for a text view. |
-accessorycommand |
script |
empty |
Runs at the global level at a tap on a button of the row, with the field and the label appended. |
focus |
method |
|
Gives the keyboard focus to the field, and the keyboard opens. |
blur |
method |
|
Takes the keyboard focus from the field, and the keyboard closes. |
tapAccessory INDEX |
method |
|
Runs -accessorycommand for the button INDEX of the row, as a tap does. |
-hidden |
boolean |
0 |
1 hides the view, and its column or row closes the gap. |
-accessibilityLabel |
text |
empty |
The name that TalkBack reads: the content description of the view. |
-accessibilityHint |
text |
empty |
Android has no hint for a view: the option keeps its value and has no effect. |
Return value
new gives the object. invoke, focus, blur, and tapAccessory give an empty string.
Errors
| Error |
When |
unknown option "-X": must be ... |
The class has no such option. The message lists the options. |
value for "-X" missing |
configure has an option with no value. |
expected boolean value but got "X" |
A bad value of -secure or -enabled. |
| Platform |
Works |
| Windows |
No |
| macOS |
No |
| Linux, Wayland |
No |
| Linux, X11 |
No |
| Web |
No |
| iOS |
No: ztk::ios::TextField |
| Android |
Yes |
| Headless |
No: the namespace does not exist. |
Example
set screen [ztk::android::Screen new -title "Sign in"]
set name [$screen add textfield -placeholder Name -command {apply {{f} {puts [$f cget -text]}}}]
ztk::android::app root $screen
See also