object:setSelected()

Type Function
Library widget.*
Return value none
Revision 2017.3060
Keywords widget, tab bar, TabBarWidget, setSelected
See also widget.newTabBar()
TabBarWidget

Overview

Use this method to set a specific TabBarWidget button to its "selected" state. Optionally, you can invoke the onPress listener for the button at the same time.

Syntax

object:setSelected( buttonIndex )
object:setSelected( buttonIndex, simulatePress )
buttonIndex (required)

Number. The button index on the tab bar, starting with 1 indicating the first button from the left.

simulatePress (optional)

Boolean. If set to true, the tab button specified by buttonIndex will have its onPress listener function called. The default is false, meaning that the tab button will appear "selected" but the listener function will not be called.

Example

-- Select the third tab
tabBar:setSelected( 3 )  

-- Select the second tab button and invoke its listener function
tabBar:setSelected( 2, true )