Re: Re: Newbie: question about destruction of FLTK ojbects
"'Albrecht Schlosser' via fltk.general"
15:03 Sep 27
On 9/27/26 16:45 S ET wrote:
> cw->callback(OnMainWindowEvent,
...);
That's exactly it.
OK, but this code needs compiler flag `-fpermissive`, and even with
that it still issues a warning. changing `int OnMainWindowEvent` to
`void OnMainWindowEvent` is correct
and fixes the warning.
> 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.
Well, good luck with that.
FYI - to answer my own question: `did you ever see the output of
"Main window event: " << ev << ... ?`:
It is possible to see this message with the given
code (established as a callback) if the user tries to close the main
window by typing `Esc`. In this case the recent event is FL_SHORTCUT
(12). To test this, add
Then press `Esc` (Escape) when running the program. `fl_eventnames[int ev]` is a nice way to decode event numbers.
I think that `Esc` is the only way to trigger the callback with an
event other than FL_CLOSE. Checking for this event can be used to
prevent the user from closing the window with `Esc` which is
documented somewhere (I don't recall where exactly).
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'.