# To subscribers of the xforms list from Steve Lamont <spl@ncmir.ucsd.edu> :
> I have a strange problem with xforms 0.89.
0.89 is effectively obsolete.
> Also whatever I typed in the input is printed on the launching window
> TWICE, not once.
>
> If I enter text and hit the enter key instead of a button, everything
> works fine, Tne text is printed and the form dissappears like it should.
>
> What am I doing wrong?
It's pretty evident your doSearch() function is getting called twice
for some reason. There's nothing in fl_hide_form() that would cause
this to happen, to the best of my knowledge.
The following test application works for me.
#include <stdio.h>
#include <stdlib.h>
#include <forms.h>
extern void launch_cb(FL_OBJECT *, long);
extern void doSearch(FL_OBJECT *, long);
typedef struct {
FL_FORM *try;
void *vdata;
char *cdata;
long ldata;
} FD_try;
typedef struct {
FL_FORM *doit;
void *vdata;
char *cdata;
long ldata;
FL_OBJECT *target;
} FD_doit;
FD_try *fd_try;
FD_doit *fd_doit;
FD_try *create_form_try(void)
{
FL_OBJECT *obj;
FD_try *fdui = (FD_try *) fl_calloc(1, sizeof(*fdui));
fdui->try = fl_bgn_form(FL_NO_BOX, 150, 80);
obj = fl_add_box(FL_FLAT_BOX,0,0,150,80,"");
obj = fl_add_button(FL_NORMAL_BUTTON,20,20,100,40,"Launch It");
fl_set_object_resize(obj, FL_RESIZE_NONE);
fl_set_object_callback(obj,launch_cb,0);
fl_end_form();
fdui->try->fdui = fdui;
return fdui;
}
FD_doit *create_form_doit(void)
{
FL_OBJECT *obj;
FD_doit *fdui = (FD_doit *) fl_calloc(1, sizeof(*fdui));
fdui->doit = fl_bgn_form(FL_NO_BOX, 350, 110);
obj = fl_add_box(FL_FLAT_BOX,0,0,350,110,"");
fl_set_object_resize(obj, FL_RESIZE_NONE);
fdui->target = obj =
fl_add_input(FL_NORMAL_INPUT,60,10,270,30,"Search");
fl_set_object_resize(obj, FL_RESIZE_NONE);
obj = fl_add_button(FL_NORMAL_BUTTON,20,60,90,30,"Search");
fl_set_object_resize(obj, FL_RESIZE_NONE);
fl_set_object_callback(obj,doSearch,1);
obj = fl_add_button(FL_NORMAL_BUTTON,240,60,90,30,"Forget It");
fl_set_object_resize(obj, FL_RESIZE_NONE);
fl_set_object_callback(obj,doSearch,0);
fl_end_form();
fdui->doit->fdui = fdui;
return fdui;
}
void launch_cb(FL_OBJECT *ob, long data)
{
fl_set_input(fd_doit->target, "");
fl_show_form(fd_doit->doit, FL_PLACE_MOUSE,
FL_TRANSIENT, "Search");
}
void doSearch(FL_OBJECT *ob, long data)
{
char line[80];
/*
* Buffer overflow possible here!
*/
strcpy(line, fl_get_input(fd_doit->target));
puts(line);
fl_hide_form(fd_doit->doit);
}
int main(int argc, char *argv[])
{
fl_initialize(&argc, argv, 0, 0, 0);
fd_try = create_form_try();
fd_doit = create_form_doit();
/* show the first form */
fl_show_form(fd_try->try,FL_PLACE_CENTERFREE,FL_FULLBORDER,"try");
while ( 1 )
fl_do_forms();
return 0;
}
spl
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuhs.mil or see
http://bob.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://world.std.com/~xforms
List Archive: http://bob.usuhs.mil/mailserv/list-archives/
This archive was generated by hypermail 2b29 : Sun Dec 01 2002 - 21:00:31 EST