Is it possible to force an instanced window to become the foreground window?
The scenario is we are using several instanced windows and would like to force a specific window to the foreground if the instance we want is already open but not in the foreground. Just using the nav.openWindow will bring one of them to the foreground but not sure how to control which one. nav.openWindowInstance will just create another window which is not desired.
Edit: We do have a handle on the window object we want via the system.gui.getOpenedWindows function
If you want to the window to be on top at all times just set the layer property of the window to a higher value. You can set this value in the designer in the properties pane when you select the window. You will see a layer property. In runtime, if you want to force the window to go the foreground do the following:windows = system.gui.getOpenedWindows()
for window in windows:
if window.getName() == "Some Window Name":
window.setLayer(5) # to a higher value
Hope this helps.
Thanks. It sort of works but has some side effects. It does not actually take focus and then I cannot select other windows so I set layer back to 0 but still dont have focus on the window.
Try these scripts out.
http://www.inductiveautomation.com/forum/viewtopic.php?p=13671#p13671
This is what I use to control my instances. If a window is already open, it brings it to the front, and gives it focus.
Oops. Accidentally resurrected the old thread. Still does not quite work for me.
I suppose I do get ‘focus’ using the toFront() method but I do not get the internalFrameActivated events which should in theory be fired when focus is acquired on a frame window. I’m guessing this is why the window still does not seem to have actual focus. It is that or perhaps the button that initiated the open window is holding focus. I’ve tested using delay callbacks and see that it returns true on hasFocus() and runs the focusGained() event but does not run the internalFrameActivated event and the window does not actually appear to have focus.
After windowInstance.toFront(), add a line that says windowInstance.setSelected(1)
1 Like