FLTK logo

[fltk.general] Re: New callback directly in command, difficulty

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: New callback directly in command, difficulty "wea... Jan 26, 2022  
 

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 ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.