beetlebug

ztk::ios::TextField

Makes a field of one line of text (UITextField) with a rounded border.

Synopsis

ztk::ios::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.
-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 global level at Return, with the field appended.
-changecommand script empty Runs at the global level at each change of the text by the user, with the field appended.
-accessory list empty The labels of a row of buttons over the soft keyboard, such as {Next Done}. The last button is at the right edge. An empty list shows no row.
-accessorycommand script empty Runs at the global level at a tap on a button of the row, with the field and the label appended.
invoke method Runs the action of Return.
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, -accessibilityLabel, -accessibilityHint option As for each view (ztk::ios).
configure, cget, destroy method As for each object (ztk::ios).

Return value

new gives the object. invoke, focus, blur, and tapAccessory give an empty string.

Errors

Error When
expected boolean value but got "X" -secure or -enabled is no boolean.
unknown option "-X": must be ... Another option.

Platforms

Platform Works
Windows No
macOS No
Linux, Wayland No
Linux, X11 No
Web No
iOS Yes
Android No: ztk::android::TextField
Headless No: the namespace does not exist.

Example

set screen [ztk::ios::Screen new -title Sign-in]
$screen add textfield -placeholder Name -changecommand {apply {{f} {puts [$f cget -text]}}}
$screen add textfield -placeholder Password -secure 1
ztk::ios::app root $screen

See also