Re: XForms: Questions on fl_do_forms()

Steve Lamont (spl@szechuan.ucsd.edu)
Wed, 22 Apr 98 05:27:51 PDT

# To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> I'm new to Xforms. I have a question about the API
> fl_do_forms(). The fl_do_forms() API can emulate some kind of
> infinite loop for GUI event checking and check the whole form once
> for each call, ie. I can make the infinite loop kartificially with an
> infinite while loop as

> FL_FORM *form
> FL_OBJECT *but, *yes;
>
> // Initialization, create form, display form
> while ((but = fl_do_forms() != yes);
>
> fl_hide_form(form);

> or make fl_do_forms() to handle the infinite loop by itself. I'm
> curious which way should adopt. ...

It's really mostly a matter of style.

My preference is to do

while ( fl_do_forms() )
;

and handle all my exit cleanup in a "quit" callback of some sort but
the approach you show will also work.

Bear in mind that any active objects without callbacks (Input objects,
Sliders, etc.) will trigger a return from fl_do_forms() so
fl_do_forms() isn't really an infinite loop unto itself.

> ... If fl_do_forms() can handle event once it is
> called, what is the difference between it and fl_check_forms()?

The difference is that fl_do_forms() *only* returns if it detects an
object without a callback. Otherwise it blocks.

fl_check_forms() will process any events or other work it finds in the
queue and then (almost) always return. It should never block. (I say
"almost" since if it executes a callback that invokes an exit() it
obviously won't return -- have I split that hair finely enough?)

fl_check_forms() is most often used in a loop or function that would
otherwise not return control to the XForms event handlers for a
significant amount of time (say, greater than maybe a 100
milliseconds) and would cause the form to "freeze up."

spl

_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/