FLTK logo

Re: [fltk.general] Re: Newbie: question about destruction of FLTK ojbects

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

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

#include <FL/names.h>
and use this modified callback:

static void OnMainWindowEvent(Fl_Widget * w, void * p)
{
int ev = Fl::event();
switch (ev)
{
case FL_CLOSE:
delete w;
break;
default:
std::cout << "Main window event: " << fl_eventnames[ev] << std::endl;
break;
}
}

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).

Enjoy!

--
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 visit https://groups.google.com/d/msgid/fltkgeneral/122817c0-9f96-42ec-a72a-fcd58bac528b%40aljus.de.
[ Direct Link to Message ]
 
     
[ Previous Message ] [ New Message | Reply ] [ Next Message ]
 
 

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'.