On 03.11.2011 18:14, David wrote:
>> On 03.11.2011 17:22, David wrote:
>> Difficult to say from your description, please provide an example code,
>> so that we can help you better. You should probably use Fl::wait()
>> (without an argument, or with 0), and you MUST use a loop.
>>
>> A good example to see how to terminate the loop is in
>> src/fl_ask.cxx, line #244 (FLTK 1.3, svn):
>>
>> while (message_form->shown()) Fl::wait();
>
> I need a popup window that is there for show only, because in the same thread 
> I need to do a bunch of work that will take a long time and can't sit in 
> message loop.  So I create a window, put text on it, show the window, but it 
> won't show without flush or wait, but wait(0) does the same as one flush no 
> matter how many times called (window shows but no text).  Basicaly, show a 
> pop up, then go do something for a long time that won't call wait, then when 
> done, close the popup, then maybe do something for a while before getting 
> back to the main loop.    On close, the window goes but the background 
> doesn't get drawn when using flush or wait(0).

Even if you need it only to show data, external events like
moving another window on top of it (occluding it) can happen,
and then your window won't be redrawn.

> Fl_Window *win=new Fl_Window(x,y,w,h);
> Fl_Box *box=new Fl_Box(x,y,w,h,text);
> win->show();
>
> (need it to show here without waiting too long)
>
> do lots of stuff that takes a long time and can't call wait()

That's what Fl::check() is for. It keeps the UI responsive, but
doesn't wait for events - it only processes events that have
already been queued. You should call it every 0.1 sec. or so,
and then everything will be responsive.

> win->hide();
>
> (need it to go away here without waiting too long)

Fl::check() will do it, but this must also be called more than
once, at least on X, since there are more than one X messages
to process, and it takes a short time to send and receive them.
But if you call Fl::check() every 0.1 sec., that will do it.

> delete win;
>
> (maybe do other stuff without the wait()).

You should still call Fl::check() then, for the same reasons as
above.

BTW.: Maybe a modal window could be a better approach for your
problem ?

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

Reply via email to