Foreground Lister Tracking

When attempting to track possible changes to the foreground lister via a detached dialog it appears that foreground lister status is lost. Test button and associated code as attached. Test output as shown. Before the loop starts one of the two listers is identified as foreground but once the dialog loop is entered neither of the two listers is identified as foreground.

fgLister.dcf.txt (4.0 KB)

function OnClick(clickData)
	var fgLister;
	var dlg;
	var msg_obj;
	var cmd = DOpus.Create().Command;
	var iteration = 0;
	// --------------------------------------------------------
	// --------------------------------------------------------
	fgLister = getFG(); // Determine initial foreground lister
	if (fgLister==false) return;
	DOpus.output("Initial active tab path = "+fgLister.activetab.path);
	dlg = fgLister.dlg
	dlg.window = fgLister; // Associate with current lister (keeps on top)
	dlg.template = "dialog1";
	dlg.title = "Just Testing";
	dlg.detach = true;
		msg_obj = dlg.getmsg();
		if (msg_obj==false) break; // User clicked X to close the dialog
		DOpus.output("dialog loop iteration "+iteration+" | event = "+msg_obj.event+" | control = "+msg_obj.control);
		fgLister = getFG();
		if (fgLister!=false) DOpus.output("dialog loop iteration "+iteration+" : active tab path = "+fgLister.activetab.path);
	while (msg_obj);
	// --------------------------------------------------------

function getFG()
	for (var i = 0; i < DOpus.listers.count; i++) {
		var str = "getFG: DOpus.listers("+i+") = "+DOpus.listers(i)+" | foreground = "+DOpus.listers(i).foreground;
		if (DOpus.listers(i).foreground) {
			DOpus.output(str+" | active tab path = "+DOpus.listers(i).activetab.path);
			return DOpus.listers(i);
		else DOpus.output(str);
	DOpus.output("getFG: No lister is identified as the foreground lister");
	return false;
	<resource name="dialog1" type="dialog">
		<dialog fontsize="8" height="44" lang="" width="93">
			<control height="14" name="button1" title="Click Me" type="button" width="50" x="19" y="16" />

Is it because the dialog is the foreground window?

Is th

I am testing for foreground lister, so unless the detached dialog window is considered to be a lister I wouldn't expect it to interfere. However, I am pretty sure that the dialog is somehow involved and maybe that is indeed what is happening. If so, then I would consider it to be a bug.

There may not be any foreground lister if no lister is the foreground window.

That would be disappointing if true. If there are multiple listers then one of them is always foreground in relation to the others and if a dialog needs to know which lister to monitor, which can change over the life of a detached dialog, there should be a reliable way of determining that.

There is only one foreground window in the system, by definition.

Opus has a "last active lister" which you can obtain via scripting. That is different to the concept of a foreground window/lister, and may be what you want.

Yes, agreed. That will work for my purposes and to be fair the help for the foreground property of Lister says "Returns True if this Lister is currently the foreground (active) window."