My tabbar object is called “myTabBar”. In order to force a button press on it, I do this:
myTabBar:setSelected(3, true)
The first argument is the tab number you want to “press”. The second argument is a bool stating whether or not you want the tab bar to actually change the image of the currently selected tab.
E.g If I was on page 2, and click a button that takes me to page 3, the above function will go to page 3 and light up the 3rd tab bar button. If it was set to false, I would still go to page 3, but the 2nd tab bar button would remain lit.
Here’s the api doc for this function: http://docs.coronalabs.com/api/type/TabBarWidget/setSelected.html
I’ll include some of the creation code, just so you can see how I’ve done it.
Hopefully your setup is fairly similar:
onTabPress = function( event ) print("pressed tab "..event.target.id ) storyboard.goToScene("page"..event.target.id) end local tabButtons = { { font = myFont, label="Tab 1", defaultFile="images/tab\_1.png", overFile="images/tab\_1\_down.png", width= 100, height= 50, size = 20, onPress=onTabPress, selected=true }, { font = myFont, label="Tab 2", defaultFile="images/tab\_2.png", overFile="images/tab\_2\_down.png", width= 100, height= 50, size = 20, onPress=onTabPress, }, { font = myFont, label="Tab 3", defaultFile="images/tab\_3.png", overFile="images/tab\_3\_down.png", width= 100, height= 50, size = 20, onPress=onTabPress, }, { font = myFont, label="Tab 4", defaultFile="images/tab\_4.png", overFile="images/tab\_4\_down.png", width= 100, height= 50, size = 20, onPress=onTabPress, }, } --create tab bar object using buttons defined above myTabBar = widget.newTabBar{ width = display.contentWidth, height = 100, left = 0, top = display.contentHeight-100, buttons =tabButtons }