Jump to content

Bring dialog to front, call attention to it


photo

Recommended Posts

I have a dialog instantiated like so when user presses a button:

MyDialog d=new MyDialog();
Unigine::Widgets::addChild(d);
while(d.isDone() == 0) wait;
Unigine::Widgets::removeChild(d);
delete d;

If the user presses that button again without closing the first dialog, I avoid re-opening a second dialog. This much is working in my implementation.

To expand on this, if a dialog already exists, I would like to bring it to the front, and also visually call attention to it (perhaps by flashing briefly) if possible. Is there an example somewhere that shows how to do either of these things?

 

Link to comment

Hi Taylor,

 

for getting widget on top, you can just call setFocus. Unfortunatelly, there is no implemented flashing effect, you can write it for your own: maybe something like this:

window.setFocus();
thread([]() {
	forloop(int i = 0; 3) {
		window.setHidden(1);
		window.arrange();
		wait;
		window.setHidden(0);
		window.arrange();
		wait;
	}
	window.setFocus();
});

Try it. And other way is to open modal dialog by setPermanentFocus.

Link to comment

maxi, on 19 Jan 2016 - 8:54 PM, said:

 

for getting widget on top, you can just call setFocus.

Calling myDialog.setFocus() does not have any visible effect. The window is not brought to the front, remains where it was in Z-order.

maxi, on 19 Jan 2016 - 8:54 PM, said:

 

other way is to open modal dialog by setPermanentFocus.

Unfortunately, setPermanentFocus is not an option in this case. If opened dialog has permanent focus, user cannot interact with other dialogs or with main window.

 

 

 

Thread with widget.setColor and sleep functions is sufficient for flashing effect, thank you for the idea.

Link to comment

Upon further investigation, it appears that setFocus() is setting focus to the dialog, but not causing it to render in front of other dialogs. Clicking on area where windows are overlapping gives unexpected results.

 

I will put together a test scenario for debugging.

Link to comment

test.zip

Here is small test scenario.

 

Double-click the item in the treebox to open a dialog.

Re-arrange windows such that they are both visible but still overlapping.

Double-click the item in the treebox again.

 

The dialog is not brought to the foreground.

Link to comment
×
×
  • Create New...