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()
Properties
Modifier and Type Member Description
public property caretPosition
caretPosition as Int
Caret insertion position.
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.
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, 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, requestFocus, resolvePreferredHeight, resolvePreferredWidth, resolvedFont, setBounds