TextField
The TextField used to enter a single line text.
Properties
enabled(in bool): If set tofalsethe text field is disabled.has_error(in bool): If set totruethe text field is displayed in the error state.has_focus: (out bool): Set to true when the text field currently has the focus.text(in_out string): The text being edited.placeholder_text(in string): A placeholder text being shown when there is no text in the text field.prefix_icon(in image): Sets the icon that is displayed in front of the text.style(in TextInputStyle): Defines the style of the text field.border_style(out BorderStyle): Gets the style of the background border.icon_style(out IconStyle): Gets the style of the icon of the text field.text_style(out TextStyle): Gets the style of the text of the text field.placeholder_style(out TextStyle): Gets the style of the placeholder text.layout_style(out LayoutStyle): Gets the style of the layout.
Callbacks
_ accepted(/* text */ string): Enter was pressed.
_ edited(/* text */ string): Emitted when the text has changed because the user modified it.
Functions
focus()Call this function to focus the text field and make it receive future keyboard events.clear_focus()Call this function to remove keyboard focus from thisLineEditif it currently has the focus.set_selection_offsets(int, int)Selects the text between two UTF_8 offsets.select_all()Selects all text.clear_selection()Clears the selection.copy()Copies the selected text to the clipboard.cut()Copies the selected text to the clipboard and removes it from the editable area.paste()Pastes the text content of the clipboard at the cursor position.
Example
import { TextField } from "@vivi/magic.slint";
export component Example inherits Window {
width: 200px;
height: 25px;
TextField {
width: parent.width;
height: parent.height;
placeholder_text: "Enter text here";
}
}