# Window Instance Focus/Activation

**URL:** <https://forum.inductiveautomation.com/t/window-instance-focus-activation/2307>\
**Category:** Ignition\
**Created:** [October 29, 2010, 5:52pm UTC](https://forum.inductiveautomation.com/t/window-instance-focus-activation/2307 "2010-10-29T17:52:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![todd.be](https://avatars.discourse-cdn.com/v4/letter/t/6f9a4e/32.png) [@todd.be](https://forum.inductiveautomation.com/u/todd.be)\
**Post date:** [October 29, 2010, 5:52pm UTC](https://forum.inductiveautomation.com/t/window-instance-focus-activation/2307/1 "2010-10-29T17:52:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [October 29, 2010, 6:31pm UTC](https://forum.inductiveautomation.com/t/window-instance-focus-activation/2307/2 "2010-10-29T18:31:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![todd.be](https://avatars.discourse-cdn.com/v4/letter/t/6f9a4e/32.png) [@todd.be](https://forum.inductiveautomation.com/u/todd.be)\
**Post date:** [October 29, 2010, 7:57pm UTC](https://forum.inductiveautomation.com/t/window-instance-focus-activation/2307/3 "2010-10-29T19:57:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [October 30, 2010, 4:46am UTC](https://forum.inductiveautomation.com/t/window-instance-focus-activation/2307/4 "2010-10-30T04:46:00Z")

</div>

Try these scripts out.  
[http://www.inductiveautomation.com/forum/viewtopic.php?p=13671#p13671](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.

---

<div class="post-metadata">

**Author:** ![todd.be](https://avatars.discourse-cdn.com/v4/letter/t/6f9a4e/32.png) [@todd.be](https://forum.inductiveautomation.com/u/todd.be)\
**Post date:** [November 1, 2010, 9:06pm UTC](https://forum.inductiveautomation.com/t/window-instance-focus-activation/2307/5 "2010-11-01T21:06:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [November 2, 2010, 4:04pm UTC](https://forum.inductiveautomation.com/t/window-instance-focus-activation/2307/6 "2010-11-02T16:04:23Z")

</div>

After windowInstance.toFront(), add a line that says windowInstance.setSelected(1)
