LineEdit
A widget used to enter a single line of text. See TextEdit for a widget able to handle several lines of text.
Properties
enabled
bool default: true
When false, nothing can be entered selecting text is still enabled as well as editing text programmatically.
font-size
length default: 0px
The size of the font of the input text
has-focus
bool (out)
default: false
Set to true when the line edit currently has the focus
horizontal-alignment
enum TextHorizontalAlignment default: left
TextHorizontalAlignment
This enum describes the different types of alignment of text along the horizontal axis of a Text
element.
left
: The text will be aligned with the left edge of the containing box.center
: The text will be horizontally centered within the containing box.right
: The text will be aligned to the right of the containing box.
The horizontal alignment of the text.
input-type
enum InputType default: text
InputType
This enum is used to define the type of the input field.
text
: The default value. This will render all characters normallypassword
: This will render all characters with a character that defaults to ”*”number
: This will only accept and render number characters (0-9)decimal
: This will accept and render characters if it’s valid part of a decimal
The way to allow special input viewing properties such as password fields.
placeholder-text
string default: ""
A placeholder text being shown when there is no text in the edit field
read-only
bool default: false
When set to true, text editing via keyboard and mouse is disabled but selecting text is still enabled as well as editing text programmatically.
text
string (in-out)
default: ""
The text being edited
Functions
focus()
Call this function to focus the LineEdit 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. See also FocusHandling.
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.
Callbacks
accepted(string)
Invoked when the enter key is pressed.
edited(string)
Emitted when the text has changed because the user modified it
key-pressed(KeyEvent) -> EventResult
Invoked when a key is pressed, the argument is a KeyEvent struct. Use this callback to
handle keys before LineEdit
does. Return accept
to indicate that you’ve handled the event, or return
reject
to let LineEdit
handle it.
key-released(KeyEvent) -> EventResult
Invoked when a key is released, the argument is a KeyEvent struct. Use this callback to
handle keys before LineEdit
does. Return accept
to indicate that you’ve handled the event, or return
reject
to let LineEdit
handle it.
© 2024 SixtyFPS GmbH