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. --- documentation/src/common.dox | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'documentation/src') 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 -- cgit v1.2.3