FLTK logo

Re: [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: Re: New callback directly in command, difficulty Apprentice Jan 26, 2022  
 
Yes it works.
Added only a forgotten parentheses at the end!
Thanks

BtExit->callback([](Fl_Widget *button, void *) {
   button->window()->hide();
});


Em quarta-feira, 26 de janeiro de 2022 às 13:55:23 UTC-3, Albrecht Schlosser escreveu:
On 1/26/22 16:49 Apprentice wrote:
The solution I could find to close the window was like this. Of course if someone has a better solution, thank you too!

BtExit->callback([](Fl_Widget *, void *data) {
   ((Fl_Window*)data)->hide();
}, (void*)WinInformations);


If you add more and more code to your lambda _expression_ it seems to become easier to add a static callback...

That said, if you want to close the window that contains the BtExit button you don't need to "send" the window in the data pointer, you can also use the window() method on the exit button which is always in the Fl_Widget pointer, something like

BtExit->callback([](Fl_Widget *button, void *) {
  button->window()->hide();
};

should work (untested).

--
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/ecf0cb8e-095e-43fe-b176-cbeceb96f387n%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'.