Synchronise selected tab in strip with current page shown

Hi,

I'm using the tab strip for main page navigation, however I also have the ability to navigate to particular pages, usually detail pages, via buttons on some pages as well. If page buttons are used for navigation, the selected tab in the tab strip doesn't update to reflect the new active page. How can I easily synchronise this?

Cheers,
Nick

The Tab Strip component has a Selected Tab property. I imagine you could bind that to a client tag which is the window path of the currently opened window.

This one took me a bit to figure out, and was a while ago so I can’t explain it all in great detail.

My solution:

  1. Each window’s root container have a custom property which held the text of the window path of the window. I don’t think I was able to get this without hard-coding the path into this custom property. Each window must have the same custom property set to the proper window path text.

"winPath" = "Window/MyWindowPath"

  1. Create function in the script library that in which you pass the “winPath” to. The function is a simple if statement, my example is simplified. However, you have to go to the root container of the window that has your tab strip and dig down to get the tab strip component:
tabWindow = system.gui.getWindow('Tab Strip Window Path').getRootContainer.getComponent('tab strip component')

if tabWindow.selectedTab != winPath
    tabWindow.selectedTab = winPath
  1. Each window needs a script on the “visionWindowOpened” to call the function in #2 and pass it’s “winPath” to the function to be analyzed.

Just as richardNZ15 stated, bind the Selected Tab property of the tab strip to the “[System]Client/User/CurrentWindow” tag and the selected tab will always reflect whatever floating window is open.

2 Likes

I have a related issue. I have “bind the Selected Tab property of the tab strip to the “[System]Client/User/CurrentWindow” tag” as suggested in my application.
The issue with this is that whenever we publish to the application, “[System]Client/User/CurrentWindow” becomes blank, and then our Selected Tab just defaults to the same tab regardless of what window is opened, i.e. the tab that’s last opened in designer mode.
Is there any fix for this?

I believe there is some funny behavior with Client tag values when saving in Designer and then publishing.

Here is a response from another thread i was in:

Yes, but this doesn’t apply to [System] tags. These are read-only and are updated dynamically as you use the system.

rchung, I don’t see the behaviour you describe. When I publish, the [System]Client/User/CurrentWindow tag is set correctly with the name of the current window and the tab strip stays on the current tab.

Thanks for the replies all. I was very new to Ignition when I first posted this and didn’t realise the tab strip had the selectedTab property. I also hadn’t looked too much into how the starter project used this along with the client CurrentWindow tag.

For reference, I’ve noticed that the CurrentWindow tag doesn’t get updated properly when you run the project within the designer. This only updates properly when the project is run properly as a client from launching it from the webserver link.

I have the same problem, I did Bind the Current windows system Tag to the Selected Tab property of the Tab strip. It does worok but only in one way. The Selected Tab is reflecting the actuel page, But as soon as i click on a tab i am getting an error message “can’t write to a system Tag…”

I really need to find a way to Sync the Selected tab with the pages, cause i am using multiples rows of tab strips to navigates to my pages.

Any work around?

This should be a non-bidirectional binding. You can’t write to that tag yourself.

I understand that, but when i clic on a tab it does write on the selected tab and since it’s binded on a System
Tag i am getting an error message. In fact it does work, the Selected tab is reflecting the current page and when i click on a tab the page change, the only thing is how to get rid of the error message?

The only reason you need the binding is to reflect the page opened in the tab strip. You don’t need a binding on the selected Tab property for the tab strip to open the page itself as that’s handled by the tab strip option in the tab strip customiser dialogue.

Ok then how (where) do i bind the current windows Tag on the Tab Strip?

By the way thanks for your help.

This is what you should have:

Note ‘Bidirectional’ binding is not set.

And this is the tab strip customiser option that actually changes the page automatically:

To navigate to particular pages in a dual manner

  • from the tabStrip of a Menu AND
  • from a push button, with a correct refresh of the Menu
    Put this code on the propertyChange of your push button:

tabWindow= system.gui.getWindow(“MyTabMenu”).getComponentForPath(“Root Container.Container.MyTabStrip”)
if tabWindow.selectedTab != “WinName_Switchto”:
tabWindow.selectedTab = “WinName_Switchto”
system.db.refresh(tabWindow, ‘tabData’)

Change

  • “WinName_Switchto” by the Windows Name you want to switch to.
  • “MyTabMenu” by the windows name of your tapStrip,
  • “MyTabStrip” by your Tab trip name (the one in the MyTabMenu)

You need to use preformatting when writing code, otherwise all your indents will be removed, leaving python code invalid. Surround your code with 3 x tildes ```

I hate re-opening old threads, but I'm experiencing this issue on a project currently as well. Not sure if it's a regression, but running 8.1.38 and my tab strip navigation works fine. I have the selected tab property bound to the [System]Client/User/CurrentWindow tag and navigation works fine.

When using some chevrons I've placed on the screen with a navigation "script" configured to swap to a different window, it will navigate fine, but the tab strip doesn't always follow. I bound a label also to the [System]Client/User/CurrentWindow tag and discovered that the times when it doesn't work, it's actually lagging behind screen changes by 1 screen (when I click a different chevron, the window swaps, but then the tag will update and the tab strip will change to the window I was just on rather than the new window.) So I think it's all related to the client tag not updating properly all the time. If I click back on the tab strip, it changes like it should, and then the chevrons may or may not work to swap windows a few times properly, then they get out of sync again.

Anyone else noticing this?

In every single case I've ever seen where Vision nav "isn't working" for folks, it's because one or more of the windows involved isn't a proper "main" window, so the standard navigation functionality completely breaks down.

All the main screens for swapping are set to Floating for dock position and the Border and Titlebar Display Policies are set to When Not Maximized, which I thought was the correct/default setting. It's just odd that it will work for a few screen changes, then get out of sync.

I found the issue!

I had 2 chevrons set to Open instead of Swap by accident, which caused the problem. Once I changed them to Swap, and closed and relaunched the client, it fixed the problem.

2 Likes