LineEdit
A widget used to enter a single line of text.
Properties
enabled
: (in bool): Defaults to true. When false, nothing can be entered selecting text is still enabled as well as editing text programmatically (default value:false
)has_focus
: (out bool): Set to true when the line edit currently has the focus.has_error
: (out bool): Set to true when the line edit currently has an error.horizontal_alignment
(in enumTextHorizontalAlignment
): The horizontal alignment of the text.input_type
(in enumInputType
): The way to allow special input viewing properties such as password fields (default value:text
).placeholder_text
: (in string): A placeholder text being shown when there is no text in the edit fieldread_only
(in bool): When set to true, text editing via keyboard and mouse is disabled buttext
(in_out string): The text being editedicon
(in image): The image to show in the LineEditaction_icon
(in image): The secondary image to show in the LineEdit for the secondary action.
Functions
focus()
Call this function to focus the LineEdit and make it receive future keyboard events.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.
Callbacks
accepted(/* text */ string)
: Enter was pressed.edited(/* text */ string)
: Emitted when the text has changed because the user modified it.clicked()
: Emitted when the LineEdit was clicked.action()
: Emitted when the action icon was clicked.
Example
import { LineEdit } from from "@coop/lib.slint";
export component Example inherits Window {
width: 200px;
height: 25px;
LineEdit {
font_size: 14px;
width: parent.width;
height: parent.height;
placeholder_text: "Enter text here";
}
}