Fluid: lambda

This commit is contained in:
Matthias Melcher
2026-01-07 15:21:41 +01:00
parent e4b3713fad
commit b966e87eb9
2 changed files with 4 additions and 3 deletions

View File

@@ -164,8 +164,9 @@ protected:
const char *name_;
/** Label text of a widget. */
const char *label_;
/** If it is just a word, it's the name of the callback function. Otherwise
it is the full callback C++ code. Can be nullptr. */
/** If it is just a word, it's the name of the callback function. If it starts
with a '[', it's a lambda function. Otherwise it is the full callback
C++ code. Can be nullptr. */
const char *callback_;
/** Widget user data field as C++ text. */
std::string user_data_;

View File

@@ -1927,7 +1927,7 @@ void Widget_Node::write_widget_code(fld::io::Code_Writer& f) {
std::string ud = user_data();
if (class_name(1) && !parent->is_widget()) ud = "this";
if (callback()) {
if (callback()[0] == '[') {
if (callback()[0] == '[') { // lambda callback function
f.write_c("%s%s->callback(\n", f.indent(), var);
f.tag(Mergeback::Tag::GENERIC, Mergeback::Tag::WIDGET_CALLBACK, 0);
f.write_c_indented(callback(), 1, 0);