On 24.11.2010, at 12:23, Domingo Alvarez Duarte wrote:
 > This works, but doesn't solve the problem of some of the opened window
 > having pending work to be done.
 >
 > If some opened window has a pending work how we can allow the user to
 > cancel the application to exit and finish the pending work ?

In my world there is no "window [that] has a pending work". It's always
the application that opens windows and must decide if there is pending
work to be done.

So, if you need to check for pending work, you can do it in the window's
callback *before* closing all windows. In Ian's code this would be in
cb_close(), in your example you called it on_close().

I don't recommend this here, but if you think that you really need it,
then you could try to call each window's callback before closing it,
something like (untested):

static void cb_close(Fl_Widget*, void*) {
   Fl_Window *win;
   while (win = Fl::first_window()) {
     if (win->callback()) {
       win->do_callback();      // call each window's callback
       if (Fl::first_window() == win)
         break;                 // user decided not to close the window
     } else {
       win->hide();             // close window (no callback)
     }
   }
}


In this case, the other windows' callbacks can decide if they
should be closed, e.g. by asking the user, and they must either
hide() the window or return w/o hiding the window.

Note that the above code will close the "me" window that got the
first callback unconditionally. That may not be what you want if
another window "rejects" to be closed. But I think that you got
the idea...

Albrecht

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to