Re: XForms: Accessing objects in a form

Steve Lamont (spl@szechuan.ucsd.edu)
Wed, 18 Jun 97 13:07:14 PDT

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

> How we access the objects inside a form.
>
> To be more precise, I want to set the contents of a
> MultilineEdit object while pressing a button object.

Any named object (that is, any object given a name using the
Attributes panel of fdesign) can be accessed by referring to it via
the FD_whatever data structure generated by the create function
generated by fdesign. You can access this structure from within a
callback as follows:

void my_callback( FL_OBJECT *ob, long data )

{

FD_whatever *whatever = ( FD_whatever *) ob->form->fdui;

fl_set_object_stuff( whatever->some_other_object,
[... parameters ...] );

}

This way you don't have to fish through the list of objects in the
form.

The objects in the form are created in the order found in the form's
.fd file. This is sort of the order in which they were added to the
form. This gets altered if you create groups, etc. If you're
relatively careful in hand editing the .fd file you can change the
creation order but there's generally no point in doing so if you just
name the objects.

The only time I've ever had to chain through the object list in the
form is to alter things in a group. Then I'd do something like

void my_callback( FL_OBJECT *ob, long data )

{

FD_whatever *whatever = ( FD_whatever *) ob->form->fdui;
FL_OBJECT *obj = whatever->some_group->next;

while ( obj->type != FL_END_GROUP ) {

do_whatever( obj );
obj = obj->next;

}

}

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/