Re: XForms: problem with fl_get_input solved :)

Steve Lamont (spl@szechuan.ucsd.edu)
Mon, 13 Oct 97 07:59:31 PDT

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

> I usually define a single callback for all input fields, that I
> leave empty...
>
> void dummy_cb(FL_OBJECT *ob, long data)
> {
>
> }
>
> And then, I define two buttons to the form... an OK button, and a
> Cancel button. Pressing the OK button, will activate a callback that
> samples all data from input fields and put its into the structure, and
> the other one does the cancelation of course :-)

This works too. In fact, this is the way I usually manage Input
objects unless I need to do some special on-the-fly syntax checking,
etc.

I don't even bother with the dummy callback. I just code

while ( 1 )
( void ) fl_do_forms();

and ignore any return values from fl_do_forms() that might be
generated by any object without a callback.

I often handle sliders, counters, and other similar objects which may
not require any immediate action in the same manner. I simply
interrogate the objects for their values when I need them, obviating
the need for any sort of extra complication.

I don't know that there's a particular "right" or "wrong" way to do
this, it's simply a matter of preference. Perhaps from a maintenance
standpoint having dummy callbacks might be slightly more confusing to
a programmer who comes along later and has to maintain the code but
good commenting will probably fix that.

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/