TextInput is a single-line text field with cursor navigation, placeholder text, character limits, autocomplete suggestions, and multiple echo modes including password masking.
Quick start
Always call
TextInput::blink from init() to start the cursor blink loop. Without it, the cursor will not animate.Constructor
TextInput() creates the field with a > prompt, normal echo mode, no character limit, and an unfocused cursor.
Core methods
Value
Focus and blur
Cursor position
Placeholder text
placeholderStyle (dim by default) and the first character sits under the cursor.
Character limit
Width
width, the visible portion scrolls horizontally to keep the cursor in view.
Echo modes
- Normal
- Password
Validation
TextInput validates input internally via its ValidateFunction interface. The function receives the proposed value as a char[] after each keystroke; returning false prevents the change from being applied.
The
ValidateFunction interface is package-private. To apply input validation, subclass TextInput and override setValue to apply your own logic, or filter acceptable characters upstream before passing them to the component.Autocomplete suggestions
Styling
Key bindings
Textarea
Multi-line text editor.
Components overview
Back to all components.