# SELECTED\_FONT, Tab Strip Component, erratic behavior

**URL:** <https://forum.inductiveautomation.com/t/selected-font-tab-strip-component-erratic-behavior/6390>\
**Category:** Ignition\
**Created:** [May 6, 2013, 7:43pm UTC](https://forum.inductiveautomation.com/t/selected-font-tab-strip-component-erratic-behavior/6390 "2013-05-06T19:43:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![billmorone](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@billmorone](https://forum.inductiveautomation.com/u/billmorone)\
**Post date:** [May 6, 2013, 7:43pm UTC](https://forum.inductiveautomation.com/t/selected-font-tab-strip-component-erratic-behavior/6390/1 "2013-05-06T19:43:41Z")

</div>

I have a Tab Strip with 6 tabs. Each tab selects a different “Main” Window (incoming event also calls swapTo()). I have created a tabData dataset with SELECTED\_FONT and UNSELECTED\_FONT columns. I have bound the selectedTab to “[System]Client/User/CurrentWindow”  
I believe I am following all the best practices regarding tab strips. (If not, please advise.)

The problem is inconsistent behavior with the “setting” of the font to the SELECTED\_FONT value when a tab is selected.  
After the first couple clicks for the next half-dozen clicks it sets the SELECTED\_FONT on the tab selected three clicks ago.  
Then it catches up a click and sets the SELECTED\_FONT on the tab clicked just previous to the last click.  
After another pass through the tabs or so, it sets the SELECTED\_FONT properly - on the tab clicked.

1. This seems like a defect - is it a known defect?

I tried hard-setting the font to the selected value with a variety of code constructs but was not able to get to the font property of the selectedTab (TabBar.Tab Strip.selectedTab.font) - has anyone done this?

1. Are the properties of the selectedTab “reachable” via script?  
Thank you.

---

<div class="post-metadata">

**Author:** ![samson.miller](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@samson.miller](https://forum.inductiveautomation.com/u/samson.miller)\
**Post date:** [May 7, 2013, 5:57pm UTC](https://forum.inductiveautomation.com/t/selected-font-tab-strip-component-erratic-behavior/6390/2 "2013-05-07T17:57:55Z")

</div>

1. It’s not a know defect. We’ll look into it.

2. Yes. For example, here’s a way to change the Font of the selected tab using scripting:

```auto
from java.awt import Font

tabStripDataset = event.source.parent.getComponent('Tab Strip').tabData
selectedTab = event.source.parent.getComponent('Tab Strip').selectedTab
pyDataset = system.dataset.toPyDataSet(tabStripDataset)

i=0
for row in pyDataset:
	
	if row. __getitem__ ("NAME") == selectedTab:
		family = "Times New Roman" 
		size = 14 
		style = Font.PLAIN 
		font = Font(family,style,size)
		newDataset = system.dataset.setValue(tabStripDataset,i,"SELECTED_FONT",font)
		event.source.parent.getComponent('Tab Strip').tabData = newDataset
		break
	i+=1  
```

---

<div class="post-metadata">

**Author:** ![billmorone](https://avatars.discourse-cdn.com/v4/letter/b/82dd89/32.png) [@billmorone](https://forum.inductiveautomation.com/u/billmorone)\
**Post date:** [May 7, 2013, 8:50pm UTC](https://forum.inductiveautomation.com/t/selected-font-tab-strip-component-erratic-behavior/6390/3 "2013-05-07T20:50:47Z")

</div>

Hi Samson,  
Great work, nice code!  
I understand what you have done, however, not exactly what I had in mind. (Sorry, not enough detail!)  
I was wondering if there was a way to actually set the font on the Tab Strip.selectedTab, (not the fonts in the table), perhaps driven by an event, a la:

`window = system.gui.getParentWindow(event)
windowname = window.name
tStrip = window.rootContainer.getComponent("Tab Strip")
tDatComp = tStrip.tabData
selTab = tStrip.selectedTab
data = tDatComp.data
for row in range(data.rowCount): 
   nameVar = data.getValueAt(row, "NAME")
   selFont = data.getValueAt(row, "SELECTED_FONT")
   if windowname == nameVar:
   	selTab.font=toFont(selFont)`

Of course, if the selected\_font of the control worked it would be unnecessary! (It is supposed to just happen - I was trying to force it)

Thank you!

---

<div class="post-metadata">

**Author:** ![samson.miller](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@samson.miller](https://forum.inductiveautomation.com/u/samson.miller)\
**Post date:** [May 7, 2013, 9:44pm UTC](https://forum.inductiveautomation.com/t/selected-font-tab-strip-component-erratic-behavior/6390/4 "2013-05-07T21:44:57Z")

</div>

I forgot to mention something. The current window means, “the window that is currently maximized” and nothing is ever maximized in the designer. So, the binding to “[System]Client/User/CurrentWindow”  
won’t work in the designer, but will work on the client. Also, check out the part in the user manual that covers “common navigation strategy” for navigation best practices.
