Tab navigation triggered from a button

I have a few views that use tabs and essentially use a svg “map” to switch tabs. Right now I sort of have it working with an on-click script writing to a memory tag and then the “currentTabIndex” bound to that memory tag. But that creates the problem of now re-setting that memory tag every single time I want to use the other tab elements. There has to be a better way I’m sure but my attempts are targeting tags with the usual self.parent/child/view etc. schema has been futile. What am I doing wrong/does someone have a best practices way of going about this?

Some clarity might help here.

Are you using a Tab Container to manage your tabs? If not, a detailed breakdown of your View or the View itself might help others provide a better way. If so, I don't understand the use of svgs to drive the tabs.

Memory tags are almost never the right way to store a state in Perspective because the tags are shared among all active sessions.

Until you can provide some clarity, this is the way I would have recommended you set up your View.
provide a custom property tabIndex for each of your svgs. Configure an onClick event for each svg with the following code:

# adjust path as necessary to point to your Tab Container
self.getSibling('TabContainer').props.currentTabIndex = self.custom.tabIndex

Honestly the memory tag was a last ditch attempt to get the thing working and I’m happy to hear that it’s wrong. I basically set it up exactly as you wrote your script before trying the memory tag, but as you said, there is more to this.

Ok, for greater specificity: I am using a tab container where clicking on an object image in the first tab will then switch the tabs. The idea basically being that you have an overview P&ID and then when you want to “zoom” into a component it just switches the tab.

I honestly think that the problem I’m having is targeting the tab container from another view that is then inside the page, but not in the same view as the controlling SVG/button.

I’ve tried self.view.getChild(‘tab container name’).props.currentTabIndex and‘tab container name’).props.currentTabIndex which just gives me a script error. I’ve also tried self.session.pageId(‘theID’) or something? I’ve tried trouble shooting this with having the returns tied to labels but it’s really getting me no where.

This is indeed your problem. You can either create a session custom property to drive the Tab Container's active tab, or you could set up a Message Handler pattern where your svgs each "broadcast" (at the page scope) the active tab to be used and the Tab Container listens (again, on the page scope) for the message and then acts when it hears it.

But... when you try that from within the "nested" view, Tab Container is not a child of the View.

And... Perspective pages know nothing of the view which is displayed. A page has a Primary View configured as part of the page ocnfiguration, but that view could always be swapped out by system.perspective.navigate(view='ViewName'), so there is no way for a Page to "know" anything about the View in use. A page only knows about its own path, the pageId assigned to the tab, and the session the page is a part of.

When you attempt to set up a binding or work with properties in a script and you use the property selector, the displayed properties are the ONLY properties you have access to; if you don't see something there, your current context has no access to it.