|
|
On Wednesday, January 26, 2022 at 2:54:45 PM UTC+1 Apprentice wrote:
Trying new callback directly in command
Wininformations is created provisionally to show a msg, and then I want to remove it completely from memory.
I can not make callback recognize WinInformations. So I can close it.
And I also can not keep the window open for a few seconds because using the sleep command the window is not shown before, as it should!
Is it possible to do that?
If you are brave enough you can pass the pointer WinInformation to the callback. This kind of callback can pass a user data.
https://www.fltk.org/doc-1.3/classFl__Widget.html#ad5fe4ff0d0f777af13f3d8818c869689
Thanks!
{ Fl_Window *WinInformations = new Fl_Window(230, 100); WinInformations->border(0); WinInformations->position((WinGrid->w() - WinInformations->w())/2 + WinGrid->x(), (WinGrid->h() - WinInformations->h())/2 + WinGrid->y()); WinInformations->set_modal();
{ Fl_Button *BtExit = new Fl_Button(90, 60, 60, 25); BtExit->label("Exit"); //BtExit->callback([](Fl_Widget*, void*) {WinInformations->hide();}); // NO WORK
//BtExit->callback([WinInformations](Fl_Widget*, void*) {WinInformations->hide();}); // NO WORK
BtExit->callback([](Fl_Widget*, void *WinInformations) { Fl_Window *Win = (Fl_Window*)WinInformations; //Win->hide(); // Segmentation fault //delete Win; // NO WORK });
} WinInformations->show(); //sleep(10); // Does not display the above window with this sleep //WinInformations->hide(); }
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/f33c7047-23ef-45ad-9c00-134d8ad60a59n%40googlegroups.com.
[ Direct Link to Message ] | |
|
| |