Documentation Index
Fetch the complete documentation index at: https://mintlify.com/fltk/fltk/llms.txt
Use this file to discover all available pages before exploring further.
Fl_Input
TheFl_Input widget displays a single line of text and allows the user to edit it. It provides comprehensive text editing capabilities with support for UTF-8, clipboard operations, and keyboard navigation.
Header File
Class Overview
Fl_Input is the standard single-line text input widget in FLTK. It features:
- Single-line text editing with full UTF-8 support
- Mouse and keyboard-based text selection
- Clipboard integration (cut, copy, paste)
- Undo/redo functionality
- Customizable appearance and behavior
- Support for input validation and filtering
Inheritance
Fl_Input_ (which inherits from Fl_Widget)
Constructor
The X coordinate of the input field relative to the enclosing window
The Y coordinate of the input field relative to the enclosing window
Width of the input field in pixels
Height of the input field in pixels
Label text displayed next to the input field
Public Methods
handle()
The FLTK event type (e.g.,
FL_KEYBOARD, FL_PUSH, FL_PASTE)int - 1 if handled, 0 otherwise
Protected Methods
draw()
Inherited Methods from Fl_Input_
TheFl_Input class inherits extensive functionality from Fl_Input_:
Text Management
value()/value(const char*)- Get or set the text contentsize()- Get the length of text in bytesmaximum_size()/maximum_size(int)- Get or set maximum text lengthinsert(const char*)- Insert text at cursor positionreplace(int, int, const char*)- Replace text in a rangecut()- Cut selected text to clipboardcopy()- Copy selected text to clipboardundo()- Undo last edit operation
Selection and Cursor
position()/position(int)- Get or set cursor positionmark()/mark(int)- Get or set selection markposition(int, int)- Set cursor position and selection markinsert_position()- Get current cursor position
Appearance
textcolor()/textcolor(Fl_Color)- Get or set text colortextfont()/textfont(Fl_Font)- Get or set text fonttextsize()/textsize(Fl_Fontsize)- Get or set text sizecursor_color()/cursor_color(Fl_Color)- Get or set cursor color
Behavior
readonly()/readonly(int)- Get or set read-only modewrap()/wrap(int)- Get or set text wrapping (multiline variants)tab_nav()/tab_nav(int)- Control tab key navigation
Mouse and Keyboard Bindings
Mouse Operations
| Mouse Action | Behavior |
|---|---|
| Button 1 Click | Moves cursor to click point |
| Button 1 Drag | Selects characters |
| Double Click | Selects word |
| Triple Click | Selects all text |
| Shift+Click | Extends selection |
| Button 2 | Pastes selection buffer at click point |
| Button 3 | Acts like button 1 |
Keyboard Shortcuts
Windows/Linux → Mac → Function
| Windows/Linux | Mac | Function |
|---|---|---|
| Ctrl+A | Cmd+A | Select all text |
| Ctrl+C | Cmd+C | Copy to clipboard |
| Ctrl+V | Cmd+V | Paste from clipboard |
| Ctrl+X | Cmd+X | Cut to clipboard |
| Ctrl+Z | Cmd+Z | Undo |
| Shift+Ctrl+Z | Shift+Cmd+Z | Redo |
| Backspace | Backspace | Delete character left |
| Delete | Delete | Delete character right |
| Shift+Delete | Shift+Delete | Cut to clipboard |
| Shift+Insert | - | Paste from clipboard |
| Arrow Keys | Arrow Keys | Cursor movement (combine with Shift to select) |
| Home | Cmd+Left | Move to start of line |
| End | Cmd+Right | Move to end of line |
| Ctrl+Left | Alt+Left | Move word left |
| Ctrl+Right | Alt+Right | Move word right |
| Ctrl+Backspace | Alt+Backspace | Delete word left |
| Ctrl+Delete | Alt+Delete | Delete word right |
Usage Example
Fromtest/input.cxx:
Advanced Example: Input Validation
Input Variants
FLTK provides several specialized input classes:- Fl_Float_Input - Validates floating-point numbers
- Fl_Int_Input - Validates integer numbers
- Fl_Secret_Input - Password field (displays bullets)
- Fl_Multiline_Input - Multi-line text input
- Fl_File_Input - File path input with browse button
See Also
- Fl_Output - Read-only text display
- Fl_Text_Editor - Advanced multi-line text editor
- Fl_Text_Display - Multi-line text display
- Fl_Input_ - Base class for input widgets