Re: XForms: problem with fl_get_input solved :)

Orn E. Hansen (oe.hansen@oehansen.pp.se)
Mon, 13 Oct 1997 15:01:33 +0200 (CEST)

To subscribers of the xforms list from "Orn E. Hansen" <oe.hansen@oehansen.pp.se> :

=DEann 13-Okt-97 skrifar Steve Lamont:
> To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lam=
ont) :
>=20
>> ... One other question I have regards program
>> structure. I have about 10 different input fields in my
>> application. I presently also have a call back for each one of
>> them. This, to me, seems a bit excessive to have 10 callbacks being
>> a few lines of code each. Is there a more efficient way of doing
>> this? Is it possible to use the same call back for the different
>> fields that pass data to the same structure? ...
>=20
> It's possible but it may not be worth the effort.
>=20
> You need to somehow differentiate the object for which the callback is
> being called. You can do this by using the long data value passed in
> the callback arguments. Define some set of constants which identify
> the fields, set them in the `Argument' field of the fdesign Attribs
> window, and then use a switch statement to choose between them at run
> time:
>=20

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 :-)

-------------------------------------------------------------------------=

---
Orn Einar Hansen                         oe.hansen@oehansen.pp.se
                                          oehansen@daimi.aau.dk
                                        voice+fax; +46 035 217194
_________________________________________________
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/