summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2025-12-22 23:12:25 +0100
committerMatthias Melcher <github@matthiasm.com>2025-12-22 23:12:42 +0100
commit33199dab785daaa7c6c5733021ad0cab48e0e1dd (patch)
tree7430470aace60b830659ca4d229727aa1f6f6112 /test
parentd0d2e104e9d5303ac897f5d1faca582e619180b2 (diff)
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.
Diffstat (limited to 'test')
-rw-r--r--test/preferences.fl16
1 files changed, 15 insertions, 1 deletions
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<Fl_Check_Button*>(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 {