[XForms] Re: [PATCH] Double clicking doesn't work in file selectors

Mike Heffner mheffner at vt.edu
Tue Dec 2 19:16:15 EST 2003


Michal,

Try the attached patch. This appears to work and is much simpler than the
current version, but I'll have to look further into the xforms event
handling code to see whether this causes a race condition. Anyone know?


Mike


On 19-Nov-2003 Michal Szymanski wrote:
| To subscribers of the xforms list
| 
| 
| Hi XFormers,
| 
| I'd like to know what the current status of "file selector double-click"
| bug is? There were a couple of messages regarding this in May, starting
| with a patch proposed by Mike Heffner, but the discussion that followed
| raised some doubts. It ended with following message from Mike: 
| 
|> However, we still have the same problem that the callback is never
|> getting
|> a ButtonPress event. ;-(
|> 
|> This weekend I'll try rewriting the file selector's callback using the
|> fl_set_browser_dblclick_callback(). It seems that might be a much
|> easier
|> way of approaching this.
| 
| Mike, did you try the rewrite?
| 
| If no, is Mike's patch included in any (CVS maybe) version of code?
| 
| I have some heavily-used XForms apps dating back to ver. 0.88 and I'd
| like very much to rebuild them with 1.0 (also because of problems with
| static libraries under RedHat 9) but all users here are quite used to
| double-clicking in file selector. The problems started already in 0.89
| and, sadly, have propagated into 1.0.
| 
| regards, Michal.
| 



-- 
  Mike Heffner       <mheffner@[acm.]vt.edu>
                         <mikeh at FreeBSD.org>

-------------- next part --------------
--- lib/fselect.c	Sat Jun  1 18:09:38 2002
+++ /home/spock/fselect.c	Tue Dec  2 19:06:46 2003
@@ -308,24 +308,18 @@
     }
     return 0;
 }
+
 #else
-/*
- * A file is selected from the browser. 
- * generate ready if valid selection (e.g. double-clicked)
- * Note that if a call back is defined, never generate ready
- */
+
 static void
-select_cb(FL_OBJECT * ob, long arg)
+select_cb(FL_OBJECT *ob, long isdblclick)
 {
     int dir;
     char seltext[FL_PATH_MAX];
-    static int lastline = -1, clicked;
-    int dblclick, thisline;
+    int thisline;
     FD_fselect *lfs = ob->form->fdui;
-    const XEvent *xev = fl_last_event();
 
     thisline = fl_get_browser(ob);
-
     if (thisline <= 0)
 	return;
 
@@ -335,31 +329,9 @@
 
     strcpy(seltext, seltext + 2);
 
-    dblclick = (lastline == thisline && clicked &&
-		fl_time_passed(FL_FS_T) < ob->click_timeout * 0.001f);
-
-    lastline = thisline;
-
-    clicked = (clicked || xev->type == ButtonPress);
-
-    /* cursor keys can cause a single line being repeatedly selected 
-       causing a wrong dblclick detection */
-
-    if (clicked)
-    {
-	if (xev->type == KeyPress || xev->type == KeyRelease)
-	{
-	    dblclick = 0;
-	    clicked = 0;
-	    lastline = -1;
-	}
-    }
-
-    fl_reset_time(FL_FS_T);
-
     if (dir)
     {
-	if (dblclick)
+	if (isdblclick)
 	{
 	    strcat(append_slash(lfs->dname), seltext);
 	    fl_fix_dirname(lfs->dname);
@@ -374,7 +346,7 @@
 	fl_set_input(lfs->input, seltext);
 	strcpy(lfs->filename, seltext);
 
-	if (dblclick)
+	if (isdblclick)
 	{
 	    if (lfs->fselect_cb)
 	    {
@@ -385,7 +357,6 @@
 		fl_object_qenter(lfs->ready);
 	}
     }
-    return;
 }
 #endif
 
@@ -964,6 +935,7 @@
     fs->browser = obj = fl_add_browser(FL_HOLD_BROWSER, 15, 80, 185, 180, "");
 #if ATTACHABLE
     fl_set_object_callback(obj, select_cb, 0);
+    fl_set_browser_dblclick_callback(obj, select_cb, 1);
 #endif
     fl_set_object_gravity(obj, NorthWestGravity, SouthEastGravity);
     obj->click_timeout = FL_CLICK_TIMEOUT;


More information about the Xforms mailing list