Re: XForms: u_vdata

Steve Lamont (spl@szechuan.ucsd.edu)
Wed, 6 Aug 97 06:26:07 PDT

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

> I would like to pass some object handles to a callback via
> u_vdata. I can do it with a single object:
>
> FL_OBJECT *obj;
> FL_OBJECT *but;
>
> obj = fl_add_input(...);
> but = fl_add_button(...);
> but->u_vdata = obj;

Yes, you can do it this way. However, more recent versions of XForms
and fdesign make this sort of object handling easier.

The FL_FORM structure now has a member

void *fdui; /* for fdesign */

which is filled by the form creation routine generated by fdesign and
points to the FD_* structure for that form. Each instantiation of the
form will, of course, point to a different instantiation of the FD_*
structure.

If you're coding your own form/object creation, this structure member
is available for your use.

Say, for instance, you have a form `try':

FD_try *fd_try;

fd_try = create_form_try();

[...]

Now, in a callback routine invoked by some action for the form you can
code

void some_callback_cb( FL_OBJECT *obj, long data )

{

FD_try *fd_try = ( FD_try *) obj->form->fdui;

[...]

and the operate on any of the objects within the `try' form using
standard calls:

[...]

fl_set_object_color( fd_try->some_object, FL_BLUE, FL_GREEN );
fl_set_object_color( fd_try->some_other_object, FL_BLUE, FL_GREEN );

[...]

for example.

This structure member appeared in 0.86, I think, so earlier libraries
may not support it.

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/