Skip to main content

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.

FLTK uses several enumeration types to define events, keys, colors, fonts, box types, and other constants.

Events (Fl_Event)

Event types passed to Fl_Widget::handle() methods.

Mouse Events

EventValueDescription
FL_NO_EVENT0No event
FL_PUSH1Mouse button pressed
FL_RELEASE2Mouse button released
FL_ENTER3Mouse entered widget
FL_LEAVE4Mouse left widget
FL_DRAG5Mouse moved with button held
FL_MOVE11Mouse moved without button
FL_MOUSEWHEEL19Mouse wheel scrolled
Example:
int MyWidget::handle(int event) {
  if (event == FL_PUSH) {
    printf("Clicked at %d,%d\n", Fl::event_x(), Fl::event_y());
    return 1;
  }
  return Fl_Widget::handle(event);
}

Keyboard Events

EventValueDescription
FL_KEYDOWN / FL_KEYBOARD8Key pressed
FL_KEYUP9Key released
FL_SHORTCUT12Keyboard shortcut
Example:
int MyWidget::handle(int event) {
  if (event == FL_KEYBOARD) {
    int key = Fl::event_key();
    if (key == FL_Enter) {
      do_callback();
      return 1;
    }
  }
  return Fl_Widget::handle(event);
}

Focus Events

EventValueDescription
FL_FOCUS6Widget received focus
FL_UNFOCUS7Widget lost focus

Widget State Events

EventValueDescription
FL_SHOW16Widget became visible
FL_HIDE15Widget became invisible
FL_ACTIVATE14Widget became active
FL_DEACTIVATE13Widget became inactive

Other Events

EventValueDescription
FL_CLOSE10Window close requested
FL_PASTE17Clipboard paste event
FL_SELECTIONCLEAR18Selection was cleared
FL_DND_ENTER20Drag-and-drop entered widget
FL_DND_DRAG21Drag-and-drop moved
FL_DND_LEAVE22Drag-and-drop left widget
FL_DND_RELEASE23Drag-and-drop released
FL_FULLSCREEN25Fullscreen state changed

Key Codes

Constants for non-ASCII keys and mouse buttons.

Special Keys

ConstantValueDescription
FL_BackSpace0xff08Backspace key
FL_Tab0xff09Tab key
FL_Enter0xff0dEnter/Return key
FL_Escape0xff1bEscape key
FL_Delete0xffffDelete key

Arrow Keys

ConstantValueDescription
FL_Home0xff50Home key
FL_Left0xff51Left arrow
FL_Up0xff52Up arrow
FL_Right0xff53Right arrow
FL_Down0xff54Down arrow
FL_Page_Up0xff55Page Up
FL_Page_Down0xff56Page Down
FL_End0xff57End key

Function Keys

ConstantDescription
FL_FBase value for function keys
FL_F + nFunction key n (e.g., FL_F+1 = F1)
FL_F_LastLast function key
Example:
int key = Fl::event_key();
if (key >= FL_F && key <= FL_F_Last) {
  int fn = key - FL_F;
  printf("Function key F%d pressed\n", fn);
}

Modifier Keys

ConstantValueDescription
FL_Shift_L0xffe1Left Shift
FL_Shift_R0xffe2Right Shift
FL_Control_L0xffe3Left Control
FL_Control_R0xffe4Right Control
FL_Caps_Lock0xffe5Caps Lock
FL_Meta_L0xffe7Left Meta/Windows
FL_Meta_R0xffe8Right Meta/Windows
FL_Alt_L0xffe9Left Alt
FL_Alt_R0xffeaRight Alt

Mouse Buttons

ConstantValueDescription
FL_Button0xfee8Base for mouse buttons
FL_LEFT_MOUSE1Left mouse button
FL_MIDDLE_MOUSE2Middle mouse button
FL_RIGHT_MOUSE3Right mouse button
FL_BACK_MOUSE4Back button (side button 1)
FL_FORWARD_MOUSE5Forward button (side button 2)

Event State Flags

Bit flags returned by Fl::event_state() indicating which modifiers and buttons are pressed.
FlagValueDescription
FL_SHIFT0x00010000Any Shift key is down
FL_CAPS_LOCK0x00020000Caps Lock is on
FL_CTRL0x00040000Any Ctrl key is down
FL_ALT0x00080000Any Alt key is down
FL_NUM_LOCK0x00100000Num Lock is on
FL_META0x00400000Any Meta/Windows key is down
FL_SCROLL_LOCK0x00800000Scroll Lock is on
FL_BUTTON10x01000000Left mouse button is down
FL_BUTTON20x02000000Middle mouse button is down
FL_BUTTON30x04000000Right mouse button is down
FL_BUTTONS0x1f000000Any mouse button is down
Example:
int MyWidget::handle(int event) {
  if (event == FL_PUSH) {
    if (Fl::event_state() & FL_CTRL) {
      printf("Ctrl-Click\n");
      return 1;
    }
  }
  return Fl_Widget::handle(event);
}

Box Types (Fl_Boxtype)

Box types define how widget backgrounds are drawn.

Basic Box Types

ConstantDescription
FL_NO_BOXNo box (invisible)
FL_FLAT_BOXFlat box
FL_UP_BOXRaised box
FL_DOWN_BOXSunken box
FL_UP_FRAMERaised frame (edges only)
FL_DOWN_FRAMESunken frame (edges only)
FL_THIN_UP_BOXThin raised box
FL_THIN_DOWN_BOXThin sunken box
FL_THIN_UP_FRAMEThin raised frame
FL_THIN_DOWN_FRAMEThin sunken frame

Decorative Box Types

ConstantDescription
FL_ENGRAVED_BOXEngraved box
FL_EMBOSSED_BOXEmbossed box
FL_ENGRAVED_FRAMEEngraved frame
FL_EMBOSSED_FRAMEEmbossed frame
FL_BORDER_BOXBox with border
FL_SHADOW_BOXBox with shadow
FL_BORDER_FRAMEBorder frame
FL_SHADOW_FRAMEShadow frame

Rounded Box Types

ConstantDescription
FL_ROUNDED_BOXRounded box
FL_RSHADOW_BOXRounded box with shadow
FL_ROUNDED_FRAMERounded frame
FL_RFLAT_BOXRounded flat box
FL_ROUND_UP_BOXRound raised box
FL_ROUND_DOWN_BOXRound sunken box

Special Shapes

ConstantDescription
FL_DIAMOND_UP_BOXDiamond raised box
FL_DIAMOND_DOWN_BOXDiamond sunken box
FL_OVAL_BOXOval box
FL_OSHADOW_BOXOval box with shadow
FL_OVAL_FRAMEOval frame
FL_OFLAT_BOXOval flat box

Scheme-Specific Boxes

Each scheme (plastic, gtk+, gleam, oxy) provides its own variants of standard box types:
  • FL_PLASTIC_* - Plastic scheme boxes
  • FL_GTK_* - GTK+ scheme boxes
  • FL_GLEAM_* - Gleam scheme boxes
  • FL_OXY_* - Oxy scheme boxes
Example:
button->box(FL_UP_BOX);
window->box(FL_FLAT_BOX);

Colors (Fl_Color)

Color values are 32-bit integers. Colors can be:
  • 8-bit color map indices (0-255)
  • 24-bit RGB values (0xRRGGBB00)

Standard Colors

ConstantValueDescription
FL_FOREGROUND_COLOR0Default foreground (text) color
FL_BACKGROUND_COLOR49Default background color
FL_BACKGROUND2_COLOR7Background for text/list widgets
FL_INACTIVE_COLOR8Inactive foreground color
FL_SELECTION_COLOR15Default selection/highlight color

Named Colors

ConstantValueDescription
FL_BLACK56Black
FL_WHITE255White
FL_RED88Red
FL_GREEN63Green
FL_BLUE216Blue
FL_YELLOW95Yellow
FL_MAGENTA248Magenta
FL_CYAN223Cyan

Dark Colors

ConstantDescription
FL_DARK_REDDark red
FL_DARK_GREENDark green
FL_DARK_BLUEDark blue
FL_DARK_YELLOWDark yellow
FL_DARK_MAGENTADark magenta
FL_DARK_CYANDark cyan

Gray Scale

ConstantValueDescription
FL_GRAY032Black end of gray ramp
FL_GRAY_RAMP32Start of 24-color gray ramp
FL_NUM_GRAY24Number of gray levels

Color Functions

// Create RGB color
Fl_Color fl_rgb_color(uchar r, uchar g, uchar b);
Fl_Color fl_rgb_color(uchar gray);

// Get gray from ramp
Fl_Color fl_gray_ramp(int i);  // i = 0 to FL_NUM_GRAY-1

// Color manipulation
Fl_Color fl_lighter(Fl_Color c);
Fl_Color fl_darker(Fl_Color c);
Fl_Color fl_color_average(Fl_Color c1, Fl_Color c2, float weight);
Example:
button->color(FL_RED);
button->color(fl_rgb_color(100, 150, 200));
button->color(fl_lighter(FL_BLUE));

Fonts (Fl_Font)

Font indices into the internal font table.
ConstantValueDescription
FL_HELVETICA0Helvetica/Arial normal
FL_HELVETICA_BOLD1Helvetica/Arial bold
FL_HELVETICA_ITALIC2Helvetica/Arial italic
FL_HELVETICA_BOLD_ITALIC3Helvetica/Arial bold italic
FL_COURIER4Courier normal
FL_COURIER_BOLD5Courier bold
FL_COURIER_ITALIC6Courier italic
FL_COURIER_BOLD_ITALIC7Courier bold italic
FL_TIMES8Times Roman
FL_TIMES_BOLD9Times Roman bold
FL_TIMES_ITALIC10Times Roman italic
FL_TIMES_BOLD_ITALIC11Times Roman bold italic
FL_SYMBOL12Symbol font
FL_SCREEN13Screen font (monospace)
FL_SCREEN_BOLD14Screen font bold
FL_ZAPF_DINGBATS15Zapf Dingbats
FL_FREE_FONT16First custom font slot

Font Modifiers

ConstantValueDescription
FL_BOLD1Add to base font for bold
FL_ITALIC2Add to base font for italic
FL_BOLD_ITALIC3Add to base font for bold italic
Example:
widget->labelfont(FL_HELVETICA_BOLD);
widget->labelfont(FL_COURIER + FL_ITALIC);
widget->labelsize(16);

Alignment Flags (Fl_Align)

Flags controlling label alignment and clipping.
ConstantValueDescription
FL_ALIGN_CENTER0x0000Center horizontally and vertically
FL_ALIGN_TOP0x0001Align to top
FL_ALIGN_BOTTOM0x0002Align to bottom
FL_ALIGN_LEFT0x0004Align to left
FL_ALIGN_RIGHT0x0008Align to right
FL_ALIGN_INSIDE0x0010Draw label inside widget
FL_ALIGN_CLIP0x0040Clip label to widget bounds
FL_ALIGN_WRAP0x0080Wrap text

Combined Alignments

ConstantDescription
FL_ALIGN_TOP_LEFTTop left corner
FL_ALIGN_TOP_RIGHTTop right corner
FL_ALIGN_BOTTOM_LEFTBottom left corner
FL_ALIGN_BOTTOM_RIGHTBottom right corner
FL_ALIGN_LEFT_TOPLeft of widget, top position
FL_ALIGN_RIGHT_TOPRight of widget, top position
FL_ALIGN_LEFT_BOTTOMLeft of widget, bottom position
FL_ALIGN_RIGHT_BOTTOMRight of widget, bottom position

Image/Text Alignment

ConstantDescription
FL_ALIGN_TEXT_OVER_IMAGEDraw text over image
FL_ALIGN_IMAGE_OVER_TEXTDraw image over text (default)
FL_ALIGN_IMAGE_NEXT_TO_TEXTImage left of text
FL_ALIGN_TEXT_NEXT_TO_IMAGEText left of image
FL_ALIGN_IMAGE_BACKDROPImage as background
Example:
button->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
button->align(FL_ALIGN_TOP_LEFT);
button->align(FL_ALIGN_IMAGE_NEXT_TO_TEXT);

Callback When Flags (Fl_When)

Determines when callbacks are invoked.
ConstantValueDescription
FL_WHEN_NEVER0Never call callback
FL_WHEN_CHANGED1On value change
FL_WHEN_NOT_CHANGED2On any interaction
FL_WHEN_RELEASE4When released and changed
FL_WHEN_RELEASE_ALWAYS6When released, even if unchanged
FL_WHEN_ENTER_KEY8When Enter pressed and changed
FL_WHEN_ENTER_KEY_ALWAYS10When Enter pressed
FL_WHEN_CLOSED16When widget is closed
Example:
input->when(FL_WHEN_CHANGED);  // Live updates
input->when(FL_WHEN_ENTER_KEY);  // On Enter key

Cursor Types (Fl_Cursor)

Standard cursor shapes.
ConstantDescription
FL_CURSOR_DEFAULTDefault arrow cursor
FL_CURSOR_ARROWArrow pointer
FL_CURSOR_CROSSCrosshair
FL_CURSOR_WAITBusy indicator (hourglass)
FL_CURSOR_INSERTI-beam text cursor
FL_CURSOR_HANDPointing hand
FL_CURSOR_HELPQuestion mark
FL_CURSOR_MOVE4-pointed arrow
FL_CURSOR_NSUp/down resize
FL_CURSOR_WELeft/right resize
FL_CURSOR_NWSEDiagonal resize
FL_CURSOR_NESWDiagonal resize
FL_CURSOR_NONEInvisible cursor
Example:
window->cursor(FL_CURSOR_WAIT);
// Do long operation
window->cursor(FL_CURSOR_DEFAULT);