# Tab Strip Show Selected Tab

**URL:** <https://forum.inductiveautomation.com/t/tab-strip-show-selected-tab/9359>\
**Category:** Ignition\
**Created:** [November 19, 2014, 6:34pm UTC](https://forum.inductiveautomation.com/t/tab-strip-show-selected-tab/9359 "2014-11-19T18:34:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![denji26](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/denji26/32/5805_2.png) [@denji26](https://forum.inductiveautomation.com/u/denji26)\
**Post date:** [November 19, 2014, 6:34pm UTC](https://forum.inductiveautomation.com/t/tab-strip-show-selected-tab/9359/1 "2014-11-19T18:34:05Z")

</div>

If I set the selectedTab of a Tab Strip, but that tab is not currently on the screen because I have too many tabs to show on one screen, is there a way to set focus to that tab so that the user can see it is selected.

Currently it remains off screen so very confusing to user.

---

<div class="post-metadata">

**Author:** ![zackscriven](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zackscriven/32/7213_2.png) [@zackscriven](https://forum.inductiveautomation.com/u/zackscriven)\
**Post date:** [January 12, 2015, 7:52pm UTC](https://forum.inductiveautomation.com/t/tab-strip-show-selected-tab/9359/2 "2015-01-12T19:52:28Z")

</div>

setting the selected tab property will make the tab that navigates to that window selected.

---

<div class="post-metadata">

**Author:** ![camatt3](https://avatars.discourse-cdn.com/v4/letter/c/22d042/32.png) [@camatt3](https://forum.inductiveautomation.com/u/camatt3)\
**Post date:** [May 22, 2018, 3:03am UTC](https://forum.inductiveautomation.com/t/tab-strip-show-selected-tab/9359/3 "2018-05-22T03:03:23Z")

</div>

I was looking for a solution to this recently and ended up writing a small script to achieve it.  
I don’t know if it’s the best solution but it works for me. Call the below script in the PropertyChange event (filtered for selectedTab property) for the Tab Strip component.

```auto
# Shift the tab strip so the selected tab appears in view (when there are too many tabs to show at once).
# The Tab Strip component should be passed in to the 'tabs' parameter. 
def showSelectedTab(tabs):
	cmpnts = tabs.getComponents()
	offset = cmpnts[0]
	pnl = cmpnts[1]
	
	x = 0
	w = 0
	for c in pnl.getComponents():
		if c.isSelected():
			x = c.getX()
			w = c.getWidth()
			break
	
	tabsW = (tabs.width - offset.width)
	os = offset.getCurrentOffset()
	maxos = pnl.width - tabsW
	if maxos < 0:
		maxos = 0
		
	if x < os:
		os = x
		offset.setCurrentOffset(os)
		tabs.revalidate()
	elif x + w > os + tabsW:
		os = x - (tabsW - w)
		if os > maxos:
			os = maxos
		offset.setCurrentOffset(os)
		tabs.revalidate()

```
