summaryrefslogtreecommitdiff
path: root/documentation/src
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 /documentation/src
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 'documentation/src')
-rw-r--r--documentation/src/common.dox9
1 files changed, 4 insertions, 5 deletions
diff --git a/documentation/src/common.dox b/documentation/src/common.dox
index 5677bb5e5..ba7c0e583 100644
--- a/documentation/src/common.dox
+++ b/documentation/src/common.dox
@@ -552,11 +552,10 @@ int xyz_data;
button->callback(xyz_callback, &xyz_data);
\endcode
-\note You cannot delete a widget inside a callback, as the
-widget may still be accessed by FLTK after your callback
-is completed. Instead, use the Fl::delete_widget()
-method to mark your widget for deletion when it is safe
-to do so.
+It's also possible to use a non-capturing lambda function directly, for example:
+```
+button->callback( [](Fl_Widget*, void*) { puts("Hello"); } , nullptr );
+```
Many programmers new to FLTK or C++ try to use a
non-static class method instead of a static class method