XForms: fl_set_resource()

Steve Lamont (spl@szechuan.ucsd.edu)
Wed, 9 Sep 98 06:44:47 PDT

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

> I used
>
> fl_set_resource("flQuestion.yes.label","HOW");
> fl_set_resource("flQuestion.no.label","WHY");
> fl_show_question("How or Why",1);
>
> Can't I reset the labels back to "Yes" and "No" by using
>
> fl_set_resource("flQuestion.yes.label","Yes");
> fl_set_resource("flQuestion.no.label","No");
> fl_show_question("Yes or No",1);
>
> The labels remain HOW and WHY and do not seem to reset subsequently
> in the program to anything else.

The reason is that when the Question Goodie is invoked for the first
time, the form is created using the equivalent of a create_form_...()
call and the labels are initialized from the resources. The form is
then shown. When you terminate the form by clicking on one of the
buttons the form is not destroyed -- it is just hidden. Thus, the
next time you call fl_show_question(), it just changes the text of the
message and reshows the form. It does not consult the resources.

Schematically, it looks something like

int fl_show_question( const char *question, int button )

{

static FD_question *fd_question = NULL;
FL_OBJECT *obj;

if ( !fd_question ) {

fd_question = create_form_question();

initialize_question_from_resources( fd_question );

}

fl_show_form( fd_question->question, ... );

obj = fl_do_forms();

fl_hide_form( fd_question->question );

return obj == fd_question->yes;

}

I'm leaving a lot out but you get the idea.

The point of the resource for the Question Goodie wasn't so much to
provide dynamic button labels but to allow the application to change
the language of the buttons for the duration of the application's run.

Unfortunately, I think the only workarounds are to create your own
Question Goodie or to use the Choice goodie.

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/