Event notification for dblclk

As demonstrated by the attached test button, a static control with Notify Clicks enabled triggers both a click and a dblclk event when double clicked. Is this working as designed? If so, is there a clever way to anticipate the dblclk event and suppress whatever action is normally associated with click?

dblclk.dcf (2.2 KB)

Sample test output:

msg_obj.event = click
msg_obj.event = dblclk

Unless you have a time machine, there's no way to tell a single click will become a double-click.

The way this problem is normally handled is to set a timer on the single click, and only execute the "single click action" after the double-click period has expired.

The attached button uses a hidden check box control and a user specified delay which needs to be long enough to handle the speed of the double click. It doesn't do anything useful but demonstrates one way of distinguishing a notified double click from a single click.

dc.dcf (4.6 KB)

// Global variables
var cmd = DOpus.Create.Command, dlg = DOpus.dlg, msg_obj;
// Button code
function OnClick(clickData)
{
	// --------------------------------------------------------
	DOpus.ClearOutput();
	cmd.deselect = false;
	// --------------------------------------------------------
	var delay = dlg.GetString("",250,4,"OK|Quit","Specify double click delay in milliseconds"); // Adjust delay for your system
	if (dlg.result==0) return;
	var dc = false; // Used to distinguish double click from single click
	var str = "Using "+delay+" ms double click delay";
	// Establish a detached dialog
	dlg.template = "dialog1";
	dlg.detach = true;
	dlg.title = "Click vs Double Click";
	dlg.create;
	dlg.top = true;
	dlg.control("group1").label = str;
	dlg.show;
	sc_bg = dlg.control("static1").bg;
	dc_bg = "#FFFF00";
	do{
		msg_obj = dlg.getmsg(); // Wait for an event
		if (msg_obj==false) break;
		DOpus.output("ctl = "+msg_obj.control+", event = "+msg_obj.event);
		if (msg_obj.control=="static1") {
			if (msg_obj.event=="dblclk") {
				dlg.control("static1").bg = dc_bg;
				dlg.control("group1").label = str+" (Double)";
				DOpus.output(str);
				dc = true;
			}
			else {
				DOpus.delay(delay);
				dlg.control("check1").value = (!dlg.control("check1").value);
				dc = false;
			}
		}
		else if ((msg_obj.control=="check1") && (dc==false)) {
			dlg.control("static1").bg = sc_bg;
			dlg.control("group1").label = str+" (Single)";
			DOpus.output(str);
		}
	}
	while (msg_obj);
	// --------------------------------------------------------
}

Associated resources:

<resources>
	<resource name="dialog1" type="dialog">
		<dialog fontsize="9" height="48" lang="english" width="174">
			<control height="30" name="group1" title="Just Testing" type="group" width="162" x="6" y="6" />
			<control halign="left" height="8" name="static1" notify="yes" title="Single or Double Click" type="static" width="150" x="12" y="18" />
			<control height="10" name="check1" title="Check Box" type="check" visible="no" width="12" x="150" y="18" />
		</dialog>
	</resource>
</resources>