Re: Re: Newbie: question about destruction of FLTK ojbects
S ET
14:45 Sep 27
> cw->callback(OnMainWindowEvent, ...);
That's exactly it.
> but it doesn't remove your directory, does it?
No indeed. But in the real tiny app I'm working on, it's not UserInterface as in the mockup that is created from main, but a derived class of UserInterface, because the latter will always be modified by FLUID. Surprisingly after your comment and noting that you are right, the files that are created by the real app do disappear on exit with 'delete w', being explicitly removed in downwards destructors. They were not being removed without this handler. I'll still have to figure out why in this case, and not in the mockup.
> There is indeed much more to discover.
> Have fun with FLTK!
Yep, that's one of the many goals.
Thank you all.
Le dimanche 27 septembre 2026 à 16:08:37 UTC+2, Albrecht-S a écrit :
On 9/27/26 15:40 S ET wrote:
I got to deleting the main window in a handler, may be it's not
the optimal way though:
Unfortunately you didn't write how you established (registered) this
"handler". Its signature looks like a callback
of a widget. Since you are using `delete w` I assume that it's
established like:
cw->callback(OnMainWindowEvent, ...);
Hence this would call the callback when the window is closed by its
close button. There's no need to check for the recent event by
calling `Fl::event();` - did you ever see the output of `"Main
window event: " << ev << ...` ?
However, a callback would be a `void` function, i.e. it would return
nothing. There are other real handler() methods which are called
from event handling that must return 0 or 1, depending on whether
you used (consumed) the event. But these can only be defined if you
subclass another widget class.
Last but not least, this handler would delete the window object,
which is - as Ian and I said - not necessary, but it doesn't remove
your directory, does it?
I am happy to read the many more options you have listed;
and to note the reactivity of the forum.
So many more subtleties to discover yet.
Thank you all and regards.
Welcome. There is indeed much more to discover. If you want to learn
more about FLTK, reading the first chapters of the documentation,
which are kinda tutorials, is strongly recommended. There are also a
lot of test and example programs bundled with the FLTK library in
these folders:
/examples/ : these attempt to provide short programs with good
coding practices to new users
/test/ : all kinds of test and demo programs to test the FLTK
library itself. The code in these programs works but may not be
the recommended practice for user programs. It's a valuable
resource for learning FLTK though.
Comments are owned by the poster. All other content is copyright 1998-2026 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.