Re: XForms: deactivate button

Steve Lamont (spl@szechuan.ucsd.edu)
Tue, 22 Sep 98 06:23:07 PDT

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

> Am I using the fl_deactivate_object() improperly? I have four buttons set
> up, when button 3 is pushed, I would like to deactivate button 2. I used
> the fdesign program to create the form and both the callback name and
> button name are the same.
>
> In the calback function for button3 I use
> if(fl_get_button(ob))
> fl_deactivate_object(button2); /* button2 name I entered in fdesign
>
> I get the compile error.
> warning: passing arg 1 of `fl_deactivate_object' from incompatible pointer
> type.
> and it core dumps when button3 is pressed.
>
> Is this the correct way to deactivate a button with the callback
> functions? ...

It's hard to tell without seeing more of the code (or the actual
code).

How is `button2' defined? I presume it's a global variable of some
kind (either that or it's a function name -- which would certainly
explain the core dump!). How is it initialized? Is it, in fact,
initialized?

Generally, objects are referred to through the `fdui' structure
created by `fdesign'. For instance, if you had four buttons defined
and named, you'd end up with something that looks like

typedef struct
{
FL_FORM *form;
void *vdata;
char *cdata;
long ldata;
FL_OBJECT *button1;
FL_OBJECT *button2;
FL_OBJECT *button3;
FL_OBJECT *button4;
}
FD_some_form;

Now, assuming that you have a button callback wherein you want to
deactivate some other button, you can code something like

void button_cb( FL_OBJECT *ob, long parm )

{

if ( fl_get_button( ob ) ) {

FD_some_form *fd_some_form =
( FD_some_form *) ob->form->fdui;
FL_OBJECT *button2 = fd_some_form->button2;

fl_deactivate_object( button2 );

}

}

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/