Prerequisites
Before starting, ensure you have:- FLTK installed on your system
- A C++ compiler (GCC, Clang, Visual Studio, or Xcode)
- Basic familiarity with C++ programming
- (Optional)
fltk-configutility for easy compilation
Launching FLUID
Interactive Mode
Start FLUID from the command line:Command-line Mode
Generate code from an existing.fl file:
myproject.h and myproject.cxx without opening the GUI.
Creating Your First Project
Step 1: Create a New Project
- Launch FLUID in interactive mode
- Go to File > New (or press
Ctrl+N) - Save immediately with File > Save As (or
Ctrl+Shift+S) - Choose a filename like
hello.fl
Step 2: Create a Function
Every UI needs a function to create the interface:- Go to New > Code > Function
- Enter the function signature:
make_window() - Press OK
Step 3: Add a Window
Now add a window to your function:- Select the
make_window()function in the browser - Go to New > Group > Window (or right-click and select from menu)
- A new window appears on screen (default size 480×320)
- You can resize this window by dragging its edges
Step 4: Add Widgets
Let’s add a button to your window:- Select the window in the widget browser
- Go to New > Buttons > Button
- A button appears in your window
- Drag it to position it
- Resize it by dragging the red selection handles
You can also use the Widget Bin (Edit > Show Widget Bin or
Alt+B) to add widgets by clicking or dragging.Step 5: Set Widget Properties
Double-click the button to open the Widget Properties panel:GUI Tab
- Label: Enter “Click Me!” to set the button text
- Tooltip: Enter “This is my first button” for hover help
Style Tab
- Label Size: Adjust font size (default is usually 14)
- Label Color: Change text color
- Box: Change button appearance (try
FL_UP_BOX)
C++ Tab
- Name: Enter
my_buttonto create a variable - Callback: Enter a callback function (see below)
Step 6: Add a Callback
Buttons need callbacks to respond to clicks. In the button’s C++ tab: Callback field:Step 7: Add Required Includes
Forfl_message() to work, add includes:
- Go to New > Code > Declaration
- Enter:
#include <FL/fl_ask.h> - In the declaration properties, select public and global
- Select In Source File (or both header and source)
Complete Example Structure
Your widget browser should now show:Generating C++ Code
Now generate the actual source files:- Save your project: File > Save (
Ctrl+S) - Write code: File > Write Code (
Ctrl+Shift+C) - FLUID creates
hello.handhello.cxxin the same directory
.cxx without an asterisk when code is up to date.
Understanding Generated Code
hello.h contains:Compiling the Result
Create a Main File
Createmain.cxx:
Compile with fltk-config
The easiest way to compile FLTK applications:- Compiles
main.cxxandhello.cxx - Links with FLTK libraries
- Creates executable
main(ormain.exeon Windows)
Manual Compilation
On Linux/macOS:Run Your Application
Next Steps
Add More Widgets
Try adding:- Input field: New > Valuators > Input
- Menu bar: New > Menu > Menu Bar
- Tabs: New > Group > Tabs (then add groups inside)
- Scroll area: New > Group > Scroll
Organize with Groups
- Select multiple widgets (
Shift+Clickor drag to select) - Press
F7to group them - Groups help with layout and can have visual frames
Use Alignment Tools
- Layout > Align: Align selected widgets
- Layout > Space Evenly: Distribute widgets evenly
- Layout > Make Same Size: Uniform sizing
- Layout > Grid Settings: Configure snap grid (
Ctrl+G)
Enable Visual Guides
- Edit > Settings (
Alt+P) - Go to Layout tab
- Choose a layout preset (FLTK or Grid)
- Enable guides with Edit > Show/Hide Guides (
Ctrl+Shift+G)
Preview Generated Code
- Edit > Show Code View (
Alt+C) - Watch code update in real-time as you make changes
- Switch between Source and Header tabs
- Useful for understanding what FLUID generates
Common Workflow Tips
How do I name widgets for code access?
How do I name widgets for code access?
In the widget’s C++ tab, enter a name in the Name field. This creates a public member variable or global variable you can access from other code.
What's the difference between label and name?
What's the difference between label and name?
- Label: Text displayed on the widget (visible to users)
- Name: C++ variable name (used in code)
How do I make resizable windows?
How do I make resizable windows?
Select the widget that should resize, then check Resizable in its properties. Usually you make the main content area resizable, not buttons or controls.
Why doesn't my callback work?
Why doesn't my callback work?
Make sure:
- You’ve included necessary headers (like
<FL/fl_ask.h>) - Callback code is valid C++ syntax
- You’ve written code files after making changes
- You’ve recompiled the application
How do I delete a widget?
How do I delete a widget?
Select it and press Delete, or use Edit > Delete. To delete multiple widgets, select them all first.
Learning More
Study Examples
FLTK includes many example.fl files:
Keyboard Shortcuts
Speed up your workflow:F1: Open widget propertiesF2/F3: Move widget earlier/later in orderF7/F8: Group/ungroup widgetsCtrl+S: Save projectCtrl+Shift+C: Write code filesCtrl+Z/Ctrl+Shift+Z: Undo/redo
Build Integration
For real projects, integrate FLUID into your build system: CMakeLists.txt example:Troubleshooting
“Cannot open .fl file”- Check file permissions
- Ensure file path has no special characters
- Try absolute path instead of relative
- Not linking FLTK libraries
- Use
fltk-config --ldflagsto get correct link flags
- Declare callback function before it’s used
- Or use inline callback code
- Make sure callback signature matches:
void callback(Fl_Widget*, void*)
- Did you write code files? (
Ctrl+Shift+C) - Did you recompile?
- Did you save the project first?
Interface Guide
Master the FLUID interface and all its features