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 enum TextHorizontalAlignment): The horizontal alignment of the text.
  • input_type (in enum InputType): 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 field
  • read_only (in bool): When set to true, text editing via keyboard and mouse is disabled but
  • text (in_out string): The text being edited
  • icon (in image): The image to show in the LineEdit
  • action_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";
    }
}