diff options
| author | Matthias Melcher <github@matthiasm.com> | 2025-12-22 23:12:25 +0100 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2025-12-22 23:12:42 +0100 |
| commit | 33199dab785daaa7c6c5733021ad0cab48e0e1dd (patch) | |
| tree | 7430470aace60b830659ca4d229727aa1f6f6112 /fluid/documentation | |
| parent | d0d2e104e9d5303ac897f5d1faca582e619180b2 (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 'fluid/documentation')
| -rw-r--r-- | fluid/documentation/src/page_widget_panel.dox | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/fluid/documentation/src/page_widget_panel.dox b/fluid/documentation/src/page_widget_panel.dox index 7a1261d62..d897037e4 100644 --- a/fluid/documentation/src/page_widget_panel.dox +++ b/fluid/documentation/src/page_widget_panel.dox @@ -369,13 +369,18 @@ \image html wp_cpp_callback.png \image latex wp_cpp_callback.png "" width=7cm - The callback field can be interpreted in two ways. If the callback text is only - a single word, FLUID assumes that this is the name of an external callback - function and declares it in the header as + The callback field can be interpreted in three ways. If the callback text is + only a single word, FLUID assumes that this is the name of an external + callback function and declares it in the header as `extern void my_button_action(Fl_Button*, void*);`. - Otherwise, FLUID assumes that the text is the body of a C++ callback function - and instead creates a local static callback function. The name of the callback + If the first letter of the callback text is a '[', FLUID expects a lambda + function which will be inlined into the widget creation code. The lambda + signature must be `[](Fl_Widget*, void*)->void { ... }`. The widget pointer + can be casted to another type inside the lambda. + + Otherwise, FLUID assumes that the text is the body of a C++ function, + and a local static callback function is created. The name of the callback function is generated by FLUID and guaranteed to be unique within the file. ``` static void cb_input(Fl_Input *o, void *v) { |
