Double window: how can we detect the FL_SHOW event without subclassing?

7 views
Skip to first unread message

S ET

unread,
7:55 AM (4 hours ago) 7:55 AM
to fltk.general
Hello,

I am looking for a way to run some code when an Fl_Double_Window shows itself.

Currently, a custom handle() function in a class derived from Fl_Double_Window does the trick.

A callback on an Fl_Double_Window reacts only to FL_CLOSE and nothing else.

Would that be possible without extending Fl_Double_Window?

Thank you.

Manolo

unread,
8:51 AM (4 hours ago) 8:51 AM
to fltk.general

You can use function Fl::event_dispatch() to add a custom event dispatch function
This dispatch function will be called at each FLTK event with the event type and the receiving window
as parameters. Therein you can react when the event type is FL_SHOW and the window
is that you're interested in.

But it's so much better to just subclass Fl_Double_WIndow.

Manolo

unread,
9:03 AM (3 hours ago) 9:03 AM
to fltk.general

It turns out some platforms don't send the FL_SHOW event for toplevel windows.
The event to track should be FL_FOCUS rather than FL_SHOW.

S ET

unread,
9:03 AM (3 hours ago) 9:03 AM
to fltk.general
> But it's so much better to just subclass Fl_Double_WIndow.

Ok, it's straightforward indeed. It's just that I found myself sub-classing more often than with other toolkits and wondered if I got stuck in that spiral while ignoring other available ways.

Thank you very much. 

Reply all
Reply to author
Forward
0 new messages