Dialog Initialisation Events

The attached DlgTest button first shows a dialog with an edit control followed by two radio buttons, then shows a dialog with two radio buttons followed by an edit control. Results as shown below.

The first dialog triggers an event associated with the edit control and the second dialog triggers an event associated with the first radio button and then an event associated with the edit control. These events are triggered before the user does anything.

Is this behaviour expected? In my message loop, how can I distinguish between an event that happens without any user action and an event that is triggered when the user actually clicks a control?

Regards, AB

DlgTest.dcf (3.9 KB)



One way to ignore dialog events that are triggered before the user actually does anything is to assume that initialisation events happen very quickly - in less than a second. A modified button is attached and debug output per the screen grabs.

Is the behaviour I am seeing normal/expected? It would be nice to have a more reliable way of determining when it is safe to assume that an event is user generated.

Regards, AB

function OnClick(clickData)
{
	DOpus.clearoutput();
	if (clickData.func.qualifiers=="none") dlgshow(clickData,"dlgtest1");
	else if (clickData.func.qualifiers=="shift") dlgshow(clickData,"dlgtest2");
	else if (clickData.func.qualifiers=="ctrl") dlgshow(clickData,"dlgtest3");
}

function dlgshow(clickData,tplname)
{
	DOpus.output('Displaying "' + tplname + '" template'); 
	var dlg = DOpus.dlg;
	dlg.window = clickData.func.sourcetab;
	dlg.template = tplname;
	dlg.detach = true;
	dlg.show;
	var before, after, initialised = false, iteration = 1;
	do {
		before = DOpus.create.date;
		msg_obj = dlg.getmsg(); if (msg_obj==false) break; // User has terminated the dialog
		after = DOpus.create.date;
		// Assume that dialog initialisation activity that happens before any user activity happens within 1 second
		if (!initialised) initialised = (0<after.compare(before,"s",1));
		DOpus.output(iteration++ + ": initialised = " + initialised + " : msg_obj.event = " + msg_obj.event + " : msg_obj.control = " + msg_obj.control);
		if (!initialised) continue;
		// Only do stuff if we are past the dialog initialisation stage 
	}
	while (msg_obj);
}

[New DlgTest.dcf and one screenshot were lost during the forum migration. --Leo]

The messages are generated automatically when the controls are initialized (it's just how those Windows controls work), but thinking about it there's no good reason to pass those through. In the next update we'll block those events until dialog initialization is complete.