Focus lost from first dialog when closing second

If dialog2 is opened from dialog1 and you close dialog2 instead of the focus returning to dialog1 the lister gains focus. Similar to how you set the Dialog.window property to a parent lister window. It should be allowed so a dialog can be set as the parent window too. This would also prevent dialog2 from being able to going behind dialog1.

Thanks.

Can you post a sample script with dialog resources so I can try this here? Thanks.

In the provided sample there is two 'detached' dialogs, one opening the other with the lister set as the parent window. As it sits right now it's demonstrating what I described above.

I realize now the reason of the focusing problem was because dialog2 had the lister set as parent window, rather than not being set. If the parent window isn't set for dialog2 it solves the focusing issue but it doesn't center over the lister/dialog1 which is not a huge problem.

Since my first post I've made other discoveries that I will explain here, now.

A problem is when opening a detached dialog, from a detached dialog (See sample). You can return to the initial dialog and click buttons while dialog2 is open. If you click the button that opened dialog2 (from dialog1) while dialog2 is open, then close dialog2 it will open again right after it's closed.

Modal dialog - prevents access to other windows
Modeless dialog - allows access to other windows

As it sits right now, dialogs (at least custom dialogs) within DOpus scripting are all modeless. I think a dialog should be able to be set as a parent window so it appears centered over the window that opened it, and parent window regains focus when second dialog is closed. In addition, the option to make it modeless or a modal dialog. In the case of opening a detached dialog from another a modal type dialog would solve the problem.

Sample script:

<?xml version="1.0"?>
<button backcol="none" display="icon" label_pos="bottom" textcol="none">
	<label>Dialog Test</label>
	<icon1>#smiley</icon1>
	<function type="script">
		<instruction>@script JScript</instruction>
		<instruction>function OnClick(data)</instruction>
		<instruction>{</instruction>
		<instruction>	var msg;</instruction>
		<instruction>	var dlg = DOpus.Dlg;</instruction>
		<instruction>	dlg.window = DOpus.Listers(0);</instruction>
		<instruction>	dlg.template = &quot;dialog1&quot;;</instruction>
		<instruction>	dlg.detach = true;</instruction>
		<instruction>	dlg.Show();</instruction>
		<instruction>	</instruction>
		<instruction>	do</instruction>
		<instruction>	{</instruction>
		<instruction>		msg = dlg.GetMsg();</instruction>
		<instruction>		if (msg.event == &quot;click&quot; &amp;&amp; msg.control == &quot;button1&quot;) openDialog2();</instruction>
		<instruction>	} while (msg == true);</instruction>
		<instruction>}</instruction>
		<instruction />
		<instruction>function openDialog2()</instruction>
		<instruction>{</instruction>
		<instruction>	var msg;</instruction>
		<instruction>	var dlg = DOpus.Dlg;</instruction>
		<instruction>	dlg.window = DOpus.Listers(0);</instruction>
		<instruction>	dlg.template = &quot;dialog2&quot;;</instruction>
		<instruction>	dlg.detach = true;</instruction>
		<instruction>	dlg.Show();</instruction>
		<instruction>	</instruction>
		<instruction>	do</instruction>
		<instruction>	{</instruction>
		<instruction>		msg = dlg.GetMsg();</instruction>
		<instruction>	} while (msg == true);</instruction>
		<instruction>}</instruction>
		<instruction>==SCRIPT RESOURCES</instruction>
		<instruction>&lt;resources&gt;</instruction>
		<instruction>	&lt;resource name=&quot;dialog1&quot; type=&quot;dialog&quot;&gt;</instruction>
		<instruction>		&lt;dialog fontsize=&quot;8&quot; height=&quot;160&quot; lang=&quot;english&quot; width=&quot;250&quot;&gt;</instruction>
		<instruction>			&lt;control height=&quot;14&quot; name=&quot;button1&quot; title=&quot;dialog2&quot; type=&quot;button&quot; width=&quot;50&quot; x=&quot;100&quot; y=&quot;73&quot; /&gt;</instruction>
		<instruction>		&lt;/dialog&gt;</instruction>
		<instruction>	&lt;/resource&gt;</instruction>
		<instruction>	&lt;resource name=&quot;dialog2&quot; type=&quot;dialog&quot;&gt;</instruction>
		<instruction>		&lt;dialog fontsize=&quot;8&quot; height=&quot;100&quot; lang=&quot;english&quot; width=&quot;180&quot; /&gt;</instruction>
		<instruction>	&lt;/resource&gt;</instruction>
		<instruction>&lt;/resources&gt;</instruction>
	</function>
</button>

Also a side issue I found in dialog msg loop in javascript is...

If below is used as test condition in the msg loop the cpu usage of dopus will slowly rise each time you run the script.

do {
	msg = dlg.GetMsg();
} while (msg);

But if it's changed to

while (msg == true);

the cpu usage remains stable.

Thanks for that. We'll address this in the next update.

  • You'll be able to use a Dialog as the parent of another dialog
  • A dialog will be able to disable its parent window using the new disable_window property

Sounds good. Thanks.