Re: XForms: u_vdata

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

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

> What I want is an array of obj passed to the callback:
>
> FL_OBJECT *obj[10];
> FL_OBJECT *but;
>
> obj[0] = fl_add_input(...);
> obj[1] = fl_add_input(...);

u_vdata can be a pointer to anything. So you can create your objects
as shown then do something like

but->u_vdata = ( void *) &obj[0];
but->u_ldata = n_objs

[...]

void button_callback_cb( FL_OBJECT *obj, long data )

{

FL_OBJECT **objs = ( FL_OBJECT **) obj->u_vdata;
int n_objs = obj->u_ldata;
int i;

for ( i = 0; i < n_objs; i++ )
printf( fl_get_input( objs[i] ) );

[...]

}

or whatever you wish.

Of course,

FL_OBJECT *obj[10];

had better be declared

static FL_OBJECT *obj[10];

or otherwise accessible (for example, declared in the routine where
you create your forms and call fl_do_forms()). Otherwise you may be
pointing out into Munchkinland when the callback is called and get
strange behavior or core dumps.

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/