ataylor Posted January 15, 2016 Share Posted January 15, 2016 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
maxi Posted January 20, 2016 Share Posted January 20, 2016 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
ataylor Posted January 21, 2016 Author Share Posted January 21, 2016 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
ataylor Posted January 21, 2016 Author Share Posted January 21, 2016 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
ataylor Posted January 21, 2016 Author Share Posted January 21, 2016 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
maxi Posted January 22, 2016 Share Posted January 22, 2016 If you are using interface plugin, you need to set focus for InterfaceWindow: #ifdef HAS_INTERFACE gTestDialog.getInterface().setFocus(); #else gTestDialog.setFocus(); #endif Link to comment
ataylor Posted January 22, 2016 Author Share Posted January 22, 2016 Ah, that was what I needed. Thank you! Link to comment
Recommended Posts