Tab Strip Disabled Mode On Click - Disabled Tabs

I have a tab strip that I'm using in the disabled navigation mode. So, I'm using the onClick script to do window swapping/component visibility as needed.

On click, I look at an extra column that I added to the tabData dataset to determine which window should be swapped to (we'll call it the overview).

However, after that other components can navigate around to different sub-pages. The issue arises when, after a subsequent navigation takes place, I now click on a disabled tab on the tab strip and it navigates me back to that overview window I mentioned above. I would not expect the onClick function to fire when a disabled tab button is clicked.

How might I get around this?

Click events throughout Vision are always honored for disabled components. The actionPerformed event is the only one that typically checks for disabled. You simply need to check the disabled/enabled status yourself in the click event.

Or, perhaps, put your code in the tab components' propertyChange event.

2 Likes

propertyChange won't work here because my Selected Tab is bidirectionally bound to a client tag so that I can do some inter-sub-tab navigation (it's actually working very well, minus this one thing).

Thing is, the entire tab isn't disabled, so how would one differentiate between the different tabs within the tab strip when the onClick function is fired.

The tab strip component has an indexAtLocation(x, y) function that will give you a tab index, from 0 (or -1 if no index was found for the given x/y pair). You could use that to determine your index, then check it against your tab attribute dataset to determine if you've marked the tab enabled or disabled.

Nope, this was all wrong (good advice for a regular Swing JTabbedPane, bad advice for Vision's tab strip component).

I've tried replicating the situation and assuming that you can't use propertyChange i've ran into the issue that i can't use the value of selectedTab to see which tab was clicked since if you click on a disabled tab, it doesn't update the value of selectedTab to the disabled tab.
First thing that comes to mind to "fix" this would be to maybe add a custom property called "lastSelectedTab" and every time the onClick script fires it moves the value of selectedTab to this lastSelectedTab property and at the start of the onClick script check if the value of lastSelectedTab is different from the last.
Something like this:

if selectedTab != event.source.lastTabSelected:
	#Place the rest of your code here
	event.source.lastTabSelected = event.source.selectedTab
1 Like

I was thinking propertyChanged combined with onClick somehow. That'll do.

There is an edge case here that I'll have to work out though. Sometimes navigating back and forth between two tabs using other buttons causes an issue.

Ended just using the propertyChange script on the tab strip's selectedTab property with the old value, in addition to the onClick script

onClick:

if event.source.selectedTab == event.source.lastSelectedTab:
	val = 1
else:
	#other stuff
	event.source.lastSelectedTab = event.source.selectedTab

propertyChange:

if event.propertyName == 'selectedTab':
	if event.newValue == event.oldValue:
		val = 1
	else:
		event.source.lastSelectedTab = event.oldValue
1 Like

Any way to disable the tab strip while the window is still loading to prevent the operator from trying to swap again before loading is complete?

Which window? The window that contains the tab strip, or a different one?

A different window. This tab strip is in a docked window and is swapping main windows.

I don't remember offhand if there's any great way to monitor whether a window is fully "started up", since that's somewhat tricky to define with various async bindings potentially being at play. Phil might have a good solution.

componentRunning property change on the root container is probably the best indicator.

Haven't seen that anywhere before. Care to elaborate or point to an example?

https://forum.inductiveautomation.com/search?q=componentRunning%20propertyChange%20order%3Alatest