# Open and close docked windows

**URL:** <https://forum.inductiveautomation.com/t/open-and-close-docked-windows/55163>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [January 19, 2022, 11:14am UTC](https://forum.inductiveautomation.com/t/open-and-close-docked-windows/55163 "2022-01-19T11:14:15Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benjamin\_Nielsen](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@Benjamin\_Nielsen](https://forum.inductiveautomation.com/u/Benjamin_Nielsen)\
**Post date:** [January 19, 2022, 11:14am UTC](https://forum.inductiveautomation.com/t/open-and-close-docked-windows/55163/1 "2022-01-19T11:14:16Z")

</div>

Hello,

I would like to open a docked window when a certain main window is open. And then open a different docked window when an other main window is opened.

I have tried to do this with "InternalActions" on the specified pages, but this leaves me with an error.

Is there somehow to do this? My docked window is a top bar, that are present at all pages. Except one, where a different docked window much replace the top bar.

Thanks in advance

---

<div class="post-metadata">

**Author:** ![leonardo.godoi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/leonardo.godoi/32/27178_2.png) [@leonardo.godoi](https://forum.inductiveautomation.com/u/leonardo.godoi)\
**Post date:** [January 19, 2022, 12:01pm UTC](https://forum.inductiveautomation.com/t/open-and-close-docked-windows/55163/2 "2022-01-19T12:01:51Z")

</div>

Is this Vision or Perspective?

---

<div class="post-metadata">

**Author:** ![Benjamin\_Nielsen](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@Benjamin\_Nielsen](https://forum.inductiveautomation.com/u/Benjamin_Nielsen)\
**Post date:** [January 20, 2022, 8:03am UTC](https://forum.inductiveautomation.com/t/open-and-close-docked-windows/55163/3 "2022-01-20T08:03:04Z")

</div>

It is in Vision

---

<div class="post-metadata">

**Author:** ![leonardo.godoi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/leonardo.godoi/32/27178_2.png) [@leonardo.godoi](https://forum.inductiveautomation.com/u/leonardo.godoi)\
**Post date:** [January 20, 2022, 1:06pm UTC](https://forum.inductiveautomation.com/t/open-and-close-docked-windows/55163/4 "2022-01-20T13:06:30Z")

</div>

If you allways need a docked window but that window can change depending on the main window open, maybe you can just do the following:

1. On the window that you need a different docked window to accompany it, add the following script under the Vision Window-VisionWindowOpened event handler:

```auto
mainDockedWindow = 'Insert here the path to the window you must close'
differentDockedWindow = 'Path to the window you must open'
system.nav.closeWindow(mainDockedWindow)
system.nav.openWindow(differentDockedWindow)

```

1. On the same window, under the event handler called VisionWindowClosed, add the following script:

```auto
mainDockedWindow = 'Insert here the path to the window you must open'
differentDockedWindow = 'Path to the window you must close'
system.nav.closeWindow(differentDockedWindow)
system.nav.openWindow(mainDockedWindow)

```

So, every time you open the main window that needs a different docked window, this script will close your main docked window and open the different docked window, the one you need, then, when you close this main window, it’ll just revert what the first script did.  
You can also do the same by changing the scripts that open and close your main window.  
I hope this is what you’re looking for.

---

<div class="post-metadata">

**Author:** ![Benjamin\_Nielsen](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@Benjamin\_Nielsen](https://forum.inductiveautomation.com/u/Benjamin_Nielsen)\
**Post date:** [January 20, 2022, 1:17pm UTC](https://forum.inductiveautomation.com/t/open-and-close-docked-windows/55163/5 "2022-01-20T13:17:12Z")

</div>

Thanks for your reply.

This solution works one time. The correct docked window closes and opens when the certain pages are opened. But if I try to navigate trough some pages, and back to the certain page. It will not close the docked window and open the different docked window…

So it almost works 🙂 Just need to having it working every time I navigate to and from it.

I am using “Tap Strip” with “Swap windows” for my main pages.

---

<div class="post-metadata">

**Author:** ![leonardo.godoi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/leonardo.godoi/32/27178_2.png) [@leonardo.godoi](https://forum.inductiveautomation.com/u/leonardo.godoi)\
**Post date:** [January 20, 2022, 1:51pm UTC](https://forum.inductiveautomation.com/t/open-and-close-docked-windows/55163/6 "2022-01-20T13:51:10Z")

</div>

Maybe it’s a thing about the cache policy? You can try and change the event handler to InternalFrameActivated and InternalFrameClosed, or use this script on your Tab Strip:

```auto
if event.propertyName == 'selectedTab':
	mainDockedWindow = ""
	differentDockedWindow = ""
	differentMainWindow = 'Path to the window that uses a diff. docked window'
	if event.newValue == differentMainWindow:
		system.nav.closeWindow(mainDockedWindow)
		system.nav.openWindow(differentDockedWindow)
	else:
		system.nav.closeWindow(differentDockedWindow)
		system.nav.openWindow(mainDockedWindow)

```

---

<div class="post-metadata">

**Author:** ![Benjamin\_Nielsen](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@Benjamin\_Nielsen](https://forum.inductiveautomation.com/u/Benjamin_Nielsen)\
**Post date:** [January 20, 2022, 6:08pm UTC](https://forum.inductiveautomation.com/t/open-and-close-docked-windows/55163/7 "2022-01-20T18:08:57Z")

</div>

The scripting on Tap strip helped, with a little modification:

window = system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Tab Strip’).selectedTab

mainDockedWindow = “”  
differentDockedWindow = “”  
differentMainWindow = ‘’  
if window == differentMainWindow:  
system.nav.closeWindow(mainDockedWindow)  
system.nav.openWindow(differentDockedWindow)  
else:  
system.nav.closeWindow(differentDockedWindow)  
system.nav.openWindow(mainDockedWindow)

Thanks for your help

---

<div class="post-metadata">

**Author:** ![leonardo.godoi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/leonardo.godoi/32/27178_2.png) [@leonardo.godoi](https://forum.inductiveautomation.com/u/leonardo.godoi)\
**Post date:** [January 20, 2022, 6:26pm UTC](https://forum.inductiveautomation.com/t/open-and-close-docked-windows/55163/8 "2022-01-20T18:26:34Z")

</div>

I’m glad i was able to help.  
P.S: I also forgot to mention that my script was meant for the “propertyChange” event handler of the tab strip

---

<div class="post-metadata">

**Author:** ![Benjamin\_Nielsen](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@Benjamin\_Nielsen](https://forum.inductiveautomation.com/u/Benjamin_Nielsen)\
**Post date:** [January 20, 2022, 6:38pm UTC](https://forum.inductiveautomation.com/t/open-and-close-docked-windows/55163/9 "2022-01-20T18:38:12Z")

</div>

Yes I found out 😉

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [January 20, 2022, 8:40pm UTC](https://forum.inductiveautomation.com/t/open-and-close-docked-windows/55163/10 "2022-01-20T20:40:21Z")

</div>

This:

> [@leonardo.godoi](#):
>
> ```auto
> if event.propertyName == differentMainWindow:
> system.nav.closeWindow(mainDockedWindow)
> system.nav.openWindow(differentDockedWindow)
> else:
> system.nav.closeWindow(differentDockedWindow)
> system.nav.openWindow(mainDockedWindow)
> 
> ```

inside this:

> [@leonardo.godoi](#):
>
> `if event.propertyName == 'selectedTab':`

is not going to work as you expected. You will always fall inside else statement

---

<div class="post-metadata">

**Author:** ![leonardo.godoi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/leonardo.godoi/32/27178_2.png) [@leonardo.godoi](https://forum.inductiveautomation.com/u/leonardo.godoi)\
**Post date:** [January 20, 2022, 8:46pm UTC](https://forum.inductiveautomation.com/t/open-and-close-docked-windows/55163/11 "2022-01-20T20:46:45Z")

</div>

Yeah you’re right, i should’ve used event.newValue instead, thanks.  
I’ve edited my so i don’t misguide anyone else

---

<div class="post-metadata">

**Author:** ![cmszr3](https://avatars.discourse-cdn.com/v4/letter/c/df788c/32.png) [@cmszr3](https://forum.inductiveautomation.com/u/cmszr3)\
**Post date:** [July 27, 2023, 5:30am UTC](https://forum.inductiveautomation.com/t/open-and-close-docked-windows/55163/12 "2023-07-27T05:30:15Z")

</div>

Hi Benjamin,

I am running into the same problem and I have getting stuck with your syntax. Do you have a screenshot by chance?

Caitlyn

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [July 27, 2023, 11:44am UTC](https://forum.inductiveautomation.com/t/open-and-close-docked-windows/55163/13 "2023-07-27T11:44:28Z")

</div>

> [@cmszr3](#):
>
> stuck with your syntax

He hasn't been seen in about a year, but if you want to post the code that's erroring out, I'm sure one of us can identify the syntax problem.
