TextField

The TextField used to enter a single line text.

Properties

  • enabled (in bool): If set to false the text field is disabled.
  • read_only (in bool): When set to true, text editing via keyboard and mouse is disabled but selecting text is still enabled as well as editing text programmatically (default value: false)
  • input_type (in InputType): The way to allow special input viewing properties such as password fields (default value: text).
  • has_error (in bool): If set to true the 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.

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 this LineEdit if 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";
    }
}