TextBox
classin packageklyn.gui.windows
public class TextBox extends Widget:
└ TextBox

Editable text field.

The class now owns a real text-editing model: caret position, selection, read-only mode and insertion/deletion helpers. The native backend still has to relay keyboard and mouse events into this API for the on-screen control to become interactive.

field = TextBox("Hello")
field.insertText(" world")
field.selectAll()
Fields
Modifier and Type Member Description
public static readonly ECHO_NORMAL
ECHO_NORMAL as String = "normal"
Displays the field content as plain text.
public static readonly ECHO_PASSWORD
ECHO_PASSWORD as String = "password"
Masks the field content while keeping the real value in `text`.
Properties
Modifier and Type Member Description
public property caretPosition
caretPosition as Int
Caret insertion position.
public property echoMode
echoMode as String:
Controls how the text is rendered.
public property isReadOnly
isReadOnly as Boolean
Disables edition while keeping selection and focus support.
public property maxLength
maxLength as Int
Maximum accepted characters.
public property paddingX
paddingX as Int
Horizontal text padding.
public property placeholder
placeholder as String
Placeholder shown when the field is empty.
public property selectionEnd
selectionEnd as Int
Selection active edge.
public property selectionStart
selectionStart as Int
Selection anchor.
public property text
text as String:
Current field content.
public property textAlign
textAlign as String
Horizontal text alignment.
Properties inherited from Widget: accentColor, backgroundColor, borderColor, bottom, canFocus, cornerRadius, font, foregroundColor, hasFocus, height, isEnabled, isHovered, isManaged, isVisible, layoutParams, margin, maxHeight, maxWidth, minHeight, minWidth, parent, preferredHeight, preferredWidth, right, sizePolicy, styleClass, width, window, x, y
Constructors
Modifier and Type Member Description
public TextBox
TextBox(text as String = ""):
No summary.
Methods
Modifier and Type Member Description
public clearSelection
clearSelection() as Void:
Clears the current selection and keeps the caret at its position.
public deleteBackward
deleteBackward() as Boolean:
Deletes the current selection or the character before the caret.
public deleteForward
deleteForward() as Boolean:
Deletes the current selection or the character after the caret.
public hasSelection
hasSelection() as Boolean:
Returns true when a selection is active.
public insertText
insertText(value as String) as Boolean:
Inserts text at the caret position or replaces the current selection.
public moveCaretLeft
moveCaretLeft(extendSelection as Boolean = false) as Void:
Moves the caret to the left.
public moveCaretRight
moveCaretRight(extendSelection as Boolean = false) as Void:
Moves the caret to the right.
public override paint
paint(painter as Painter) as Void:
Paints the field with antialiasing, selection and caret.
public select
select(start as Int, end as Int = -1) as Void:
Updates the current selection range.
public selectAll
selectAll() as Void:
Selects the whole field content.
public setCaret
setCaret(position as Int) as Void:
Moves the caret to a given position.
Methods inherited from Widget: blur, containsPoint, paint, repaint, requestFocus, resolvePreferredHeight, resolvePreferredWidth, resolvedFont, setBounds