Proposal: Add a Fl_Window::show_modal() method. I've only been using
FLTK for about 2 months and I've already had an occasion to use this
four times.
Something along these lines...
void Fl_Window::show_modal()
{
show();
// Wait until hidden
do { Fl::wait(1); } while (visible());
}
The first time I wanted to write an fl_ask()-style function, I pretty
much copied fl_ask() and made it suit my needs. After that, I started
using the show_modal() method above. It's a nice clean way to achieve
fl_ask()-like behavior without having to write your own event loop.
I tend to draw a modal window in Fluid, and then I'll hide a value or
checkbox widget in it somewhere that callbacks can use. The callbacks
set the value and then hide the window. Just before I return, I can
grab the value to return to the user.
Example use:
Fl_Window *dlgwin = NULL;
Fl_Check_Button *dlgok = NULL;
// 1=ok, 0=cancel
int ask_user_ok_cancel()
{
if (!dlgwin) make_dlgwin();
if (!dlgwin) return 0;
// Let OK button callback set() dlgok
dlgok->clear();
w->show_modal();
if (dlgok->value()) return 1;
return 0;
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk