From 33199dab785daaa7c6c5733021ad0cab48e0e1dd Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Mon, 22 Dec 2025 23:12:25 +0100 Subject: FLUID: Add support for lambda callbacks. Starting the callback text with a '[' assumes that the rest of the callback is a lambda and generates inlined code for it. --- test/preferences.fl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/preferences.fl b/test/preferences.fl index a46c7faeb..dec03d2b3 100644 --- a/test/preferences.fl +++ b/test/preferences.fl @@ -7,6 +7,7 @@ i18n_gnu_function gettext i18n_gnu_static_function gettext_noop header_name {.h} code_name {.cxx} +include_guard {} comment {About test/preferences: The preferences app shows two features of FLTK and FLUID. @@ -184,6 +185,10 @@ Fl_Input::paste_menu_text = gettext("Paste");} {} } MenuItem {} { label sandals + callback {[](Fl_Widget*, void*) +{ + puts("The shoe is the sign!"); +}} selected xywh {0 0 100 20} } MenuItem {} { @@ -203,7 +208,7 @@ Fl_Input::paste_menu_text = gettext("Paste");} {} xywh {35 112 100 24} type Radio down_box ROUND_DOWN_BOX } Fl_Round_Button wRight { - label {right side} selected + label {right side} xywh {35 136 100 24} type Radio down_box ROUND_DOWN_BOX } Fl_Box {} { @@ -217,6 +222,15 @@ Fl_Input::paste_menu_text = gettext("Paste");} {} } Fl_Check_Button wShave { label shave + callback {[](Fl_Widget* w, void*)->void { + auto* btn = static_cast(w); + if (btn->value()) { + puts("Shave."); + } else { + puts("Don't shave."); + } +}} + comment {// Testing lambdas for callbacks} xywh {25 212 105 24} down_box DOWN_BOX } Fl_Check_Button wBrush { -- cgit v1.2.3