TextField
A widget used to enter a single line of text with additional features like icons and supporting text.
Properties
Section titled “Properties”enabled
Section titled “enabled”bool default: true
When false, the text field is disabled and cannot be interacted with.
has_error
Section titled “has_error”bool default: false
Indicates whether the text field should display an error state.
has_focus
Section titled “has_focus”bool (out)
default: false
Set to true when the text field currently has the focus.
string default: ""
The label text displayed above the text input.
leading_icon
Section titled “leading_icon”image default: the empty image
An icon displayed at the beginning of the text input.
placeholder
Section titled “placeholder”string default: ""
A placeholder text being shown when there is no text in the edit field.
supporting_text
Section titled “supporting_text”string default: ""
Additional text displayed below the text input, often used for hints or error messages.
string (in-out)
default: ""
The text being edited.
trailing_icon
Section titled “trailing_icon”image default: the empty image
An icon displayed at the end of the text input.
Functions
Section titled “Functions”set_selection_offsets(int, int)
Section titled “set_selection_offsets(int, int)”Selects the text between two UTF-8 offsets.
select_all()
Section titled “select_all()”Selects all text in the text field.
clear_selection()
Section titled “clear_selection()”Clears the current text selection.
Copies the selected text to the clipboard and removes it from the text field.
copy()
Section titled “copy()”Copies the selected text to the clipboard.
paste()
Section titled “paste()”Pastes the text content of the clipboard at the cursor position.
Callbacks
Section titled “Callbacks”accepted(string)
Section titled “accepted(string)”Invoked when the enter key is pressed.
TextField { accepted(text) => { debug("Accepted: ", text); }}
edited(string)
Section titled “edited(string)”Emitted when the text has changed because the user modified it.
TextField { edited(text) => { debug("Text edited: ", text); }}
key_pressed(KeyEvent) -> EventResult
Section titled “key_pressed(KeyEvent) -> EventResult”Invoked when a key is pressed, the argument is a KeyEvent struct. Use this callback to handle keys before TextField
does. Return accept
to indicate that you’ve handled the event, or return reject
to let TextField
handle it.
key_released(KeyEvent) -> EventResult
Section titled “key_released(KeyEvent) -> EventResult”Invoked when a key is released, the argument is a KeyEvent struct. Use this callback to handle keys before TextField
does. Return accept
to indicate that you’ve handled the event, or return reject
to let TextField
handle it.
leading_icon_clicked()
Section titled “leading_icon_clicked()”Invoked when the leading icon is clicked.
TextField { leading_icon_clicked() => { debug("Leading icon clicked"); }}
trailing_icon_clicked()
Section titled “trailing_icon_clicked()”Invoked when the trailing icon is clicked.
TextField { trailing_icon_clicked() => { debug("Trailing icon clicked"); }}
© 2025 SixtyFPS GmbH