> Assume a simple form called foo created by fdesign with a single input
> field called bar. I want to insert a value into the field from the
> c-language program (specifically from a callback routine, not
> necessarily the one for that field.)
>
> How do I address the field? Is it ui->bar or fdui->bar or fd_foo->bar
> or what? The examples don't seem to deal with the simple situation of
> moving data to an input field from a callback situation. I want to use a
> statement like:
>
> fl_set_input(xxx->bar, stringvalue);
>
> I just need to know what to use in place of xxx, given a form named foo
> and a field named bar. Please remember that I am using the output from
> fdesign (all three source modules) so its naming conventions are in
> force.
If it's in the callback for the object itself, you'd use
void input_callback( FL_OBJECT *ob, long data )
{
fl_set_input( ob, stringvalue );
}
If it's in some other callback in the same form, then you can do
void some_other_callback( FL_OBJECT *ob, long data )
{
FD_some_form *fd_some_form =
( FD_some_form *) ob->form->fdui;
fl_set_input( fd_some_form->bar, stringvalue );
}
If it is in some callback for some other form, then it's somewhat more
problematic. If you place your form descriptions in global variables,
then you would just code
FD_this_form *fd_this_form;
FD_that_form *fd_that_form;
FD_some_form *fd_some_form;
[...]
void some_other_forms_callback( FL_OBJECT *ob, long data )
{
fl_set_input( fd_some_form->bar, stringvalue );
}
If you want to avoid global variables as poor programming practice
then you need to attach your FD* structures to each of the forms in
some manner:
typedef struct {
FD_this_form *fd_this_form;
FD_that_form *fd_that_form;
FD_some_form *fd_some_form;
} FormStruct;
[...]
static FormStruct fs;
fd_this_form = create_form_this_form();
fd_that_form = create_form_that_form();
fd_some_form = create_form_some_form();
fs.fd_this_form = fd_this_form;
fs.fd_that_form = fd_that_form;
fs.fd_some_form = fd_some_form;
fd_this_form->vdata =
fd_this_form->vdata =
fd_this_form->vdata = &fs;
[...]
void some_different_callback( FL_OBJECT *ob, long data )
{
FD_this_form *fd_this_form =
( FD_this_form *) ob->form->fdui;
FD_some_form *fd_some_form =
( FormStruct *) fd_this_form->vdata;
fl_set_input( fd_some_form->bar, stringvalue );
}
Hope this helps.
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/