I have a docked window with a text label. I would like to dynamically change the text property on the label depending on what window is opened.
Any suggestions on how to do this.
If Control Window is selected, then display label text = “Control Window”
If Plant Overview is selected, then display label text = “Plant Overview”
It may not be the best way, but you can create a client timer script that writes the active window name to a client tag. Then bind the labels text property to that client tag.
To test it I created the “activeWindow” client tag, and set this script to run once a second:
I just thought of another way. If you are using a tab strip navigation, you could add the script from my last message to the property change event instead of doing the timer client script.
Are you using vision or perspective? For Vision you can use the system tag
Perspective is a different story. I’ve solved this by calling a function on startup of all my main views which writes to a session prop. It would be nice if there was a session prop for this already, but at the moment we’re out of luck.
Edit: I thought you might have been able to get this from the
system.perspective.getSessionInfo() function, however the pageIds that are returned are hexadecimal ids rather than actual view paths, so this isn’t useable for this. Interestingly though, the pageIds are the names of the Views for the Designer session, but they don’t include the path to the View, so even that’s not very useful for this.
Just like @nminchin, we’re using a session custom prop
currentView that stores exactly what its name says. This makes a lot of things much simpler.