Fl_Tabs creates a tabbed interface where each child group represents a tab page. Only one tab’s content is visible at a time, making it ideal for organizing related controls in limited space.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.
Key Features
- Multiple pages in same space
- Tab labels from child group labels
- Tab colors from child selection_color
- Keyboard shortcuts with ’&’ prefix
- Closeable tabs with callback support
- Four overflow handling modes
- Automatic or always-visible tabs
- Top or bottom tab placement
Creating Fl_Tabs
Important: Leave 5+ pixels of space at top or bottom of tab groups (where tabs appear) to prevent children from interfering with tab drawing.
Tab Positioning
Tabs appear at top or bottom based on available space:- More space above children: Tabs at top
- More space below children: Tabs at bottom
Tab Labels and Shortcuts
Label from Child Group
& to create keyboard shortcuts:
Tab Label Alignment
Tab Colors
Individual Tab Colors
Set each child group’scolor() and selection_color():
Highlighting Selected Tab
Set Fl_Tabs selection_color to highlight active tab:Uniform Appearance
Update Fl_Tabs selection_color in callback:Selecting Tabs
Get Current Tab
Set Current Tab
Push State
Get the tab user is clicking on:push() returns non-NULL only while mouse button is down on a tab. Returns NULL after release or if dragged away.Closeable Tabs
Enable close buttons on tabs: Close button:- Displays “X” to left of tab label
- Only shown when tab is fully expanded (not compressed)
- Calls callback with
FL_REASON_CLOSED
Overflow Handling
When tabs don’t fit, use one of four modes:- COMPRESS
- CLIP
- PULLDOWN
- DRAG
Resize Behavior
To keep tab height constant during resize:Callbacks
Control when callback is invoked:changed()- True if tab changedFl::callback_reason()- ReturnsFL_REASON_SELECTEDorFL_REASON_RESELECTED
Complete Example
Fromexamples/tabs-simple.cxx:
Common Patterns
Settings Dialog
Document Tabs with Close
Nested Tabs
Best Practices
Leave Space for Tabs
Keep 5+ pixels clear at top/bottom:
Set Resizable
Keep tab height constant:
Use Shortcuts
Add ’&’ for keyboard access:
Match Colors
Sync tab and panel colors in callback:
Reference
Header File
Key Methods
| Method | Description |
|---|---|
value() | Get current tab group |
value(Fl_Widget*) | Set current tab group |
push() | Get tab being clicked |
tab_align(Fl_Align) | Set tab label alignment |
handle_overflow(int) | Set overflow mode |
which(int x, int y) | Find tab at position |
client_area(...) | Get content area bounds |
Overflow Modes
See Also
- Fl_Group - Base container widget
- Callbacks - Event handling
- FL_WHEN_* Flags - Callback timing