XForms: browser double click question

Stephen Langer (langer@cam.nist.gov)
Mon, 2 Feb 1998 17:59:20 -0500

# To subscribers of the xforms list from "Stephen Langer" <langer@cam.nist.gov> :

--
--PART-BOUNDARY=.19802021759.ZM25121.cam.nist.gov
Content-Type: text/plain; charset=us-ascii

Hi --

I think I don't understand how the browser double-click callback is supposed to be used. I have a browser for which I'd like to perform different actions depending on whether a line is single or double clicked. So I register one callback with fl_set_object_callback() and another with fl_set_browser_dblclick_callback(). When I double click on a browser line, the single click callback is called, then the double click callback, and then the single click callback again... Is this the expected behavior? I'd have expected one callback or the other to be called, and only once.

I'm using version 0.88 for SGI, compiled with -n32 -mips3.

I've included a simple example program, in which each callback prints either "single click" or "double click" to stderr.

Thanks for any suggestions, and apologies if this has been discussed. I have a vague feeling that it has, but I couldn't find it in the archives.

-- Steve

-- 
-- EMail: stephen.langer@nist.gov                    Phone: (301) 975-5423 --
-- WWW:  http://math.nist.gov/mcsd/Staff/SLanger/    Fax:   (301) 990-4127 --
-- Mail: Building 820 Room 365; NIST; Gaithersburg, Md          20899-0001 --

--PART-BOUNDARY=.19802021759.ZM25121.cam.nist.gov X-Zm-Content-Name: dbtest.c Content-Type: text/plain ; name="dbtest.c" ; charset=us-ascii

#include <stdio.h> #include <stdlib.h> #include "forms.h" #include "dblclick.h"

#ifndef FD_dblclick_h_ #define FD_dblclick_h_ /* Header file generated with fdesign. */

/** Callback routines and free object handlers **/

extern void singleclick(FL_OBJECT *, long); extern void quitcallback(FL_OBJECT *, long);

/**** Forms and Objects ****/

typedef struct { FL_FORM *dblclick; void *vdata; char *cdata; long ldata; FL_OBJECT *browser; FL_OBJECT *quitbutton; } FD_dblclick;

extern FD_dblclick * create_form_dblclick(void);

#endif /* FD_dblclick_h_ */

/* -------------- */

/* Form definition file generated with fdesign. */

#include "forms.h" #include <stdlib.h> #include "dblclick.h"

FD_dblclick *create_form_dblclick(void) { FL_OBJECT *obj; FD_dblclick *fdui = (FD_dblclick *) fl_calloc(1, sizeof(*fdui));

fdui->dblclick = fl_bgn_form(FL_NO_BOX, 250, 230); obj = fl_add_box(FL_UP_BOX,0,0,250,230,""); fdui->browser = obj = fl_add_browser(FL_SELECT_BROWSER,50,30,150,130,""); fl_set_object_callback(obj,singleclick,0); fl_add_browser_line(obj, "line 1"); fl_add_browser_line(obj, "line 2"); fl_add_browser_line(obj, "line 3"); fl_add_browser_line(obj, "last line"); fdui->quitbutton = obj = fl_add_button(FL_NORMAL_BUTTON,90,170,60,40,"Quit"); fl_set_object_callback(obj,quitcallback,0); fl_end_form();

fdui->dblclick->fdui = fdui;

return fdui; }

/*---------------------------------------*/

static FD_dblclick *the_form;

/*ARGSUSED*/ void quitcallback(FL_OBJECT *obj, long arg) { exit(0); }

static int counter = 0; /* to distinguish output lines... */

/*ARGSUSED*/ void singleclick(FL_OBJECT *obj, long arg) { fprintf(stderr, "single click %d\n", counter++); }

/*ARGSUSED*/ void doubleclick(FL_OBJECT *obj, long arg) { fprintf(stderr, "double click %d\n", counter++); }

int main(int argc, char *argv[]) { fl_initialize(&argc, argv, "DblClick", 0, 0); the_form = create_form_dblclick(); fl_set_object_dblclick(the_form->browser, 500); fl_set_browser_dblclick_callback(the_form->browser, doubleclick, 0); fl_show_form(the_form->dblclick, FL_PLACE_MOUSE, FL_FULLBORDER, "Click Test"); for(;;) fl_do_forms(); return 0; }

--PART-BOUNDARY=.19802021759.ZM25121.cam.nist.gov--

_________________________________________________ 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://bloch.phys.uwm.edu/xforms List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/