Is it possible to run a direct command in Callback?

20 views
Skip to first unread message

Apprentice

unread,
Jan 25, 2022, 3:46:42 PM1/25/22
to fltk.general
System: Linux, Slackware64 Current
Compiler: g++
Fltk: v.1.4.0

The callback below (Fl_Button) runs the Exit function that has the command exit(0);
BtExit->callback((Fl_Callback*)Exit);

Is it possible for me to run the command exit(0); without using a function, right in this callback command? How do I do that? for example:
BtExit->callback(exit(0));

Thanks!

lifeatt...@gmail.com

unread,
Jan 25, 2022, 5:22:44 PM1/25/22
to fltk.general
Might try using a lambda [I've not tried it ...]  Will require C++11.

BtExit->callback( [](Fl_Widget *, void *) { exit(0); } );

Apprentice

unread,
Jan 25, 2022, 10:26:59 PM1/25/22
to fltk.general
Yes this works perfectly!
Thank you so much!

Reply all
Reply to author
Forward
0 new messages