class TabBar
package feathers.controls
extends FeathersControl › MeasureSprite › ValidatingSprite
implements IFocusObject, IDataSelector<Dynamic>, IIndexSelector
A line of tabs, where one may be selected at a time.
The following example sets the data provider, tells the tabs how to interpret the data, selects the second tab, and listens for when the selection changes:
var tabs = new TabBar();
tabs.dataProvider = new ArrayCollection([
{ text: "Latest Posts" },
{ text: "Profile" },
{ text: "Settings" }
]);
tabBar.itemToText = (item:Dynamic) -> {
return item.text;
};
tabs.selectedIndex = 1;
tabs.addEventListener(Event.CHANGE, tabs_changeHandler);
this.addChild(tabs);
Events:
openfl.events.Event.CHANGE | Dispatched when either
|
---|---|
feathers.events.TabBarEvent.ITEM_TRIGGER | Dispatched when the user taps or clicks a tab. The pointer must remain within the bounds of the tab on release, or the gesture will be ignored. |
1.0.0
.See also:
Static variables
staticfinalread onlyCHILD_VARIANT_TAB:String = "tabBar_tab"
The variant used to style the tab child components in a theme.
To override this default variant, set the
TabBar.customTabVariant
property.
1.0.0
.See also:
Constructor
Variables
backgroundSkin:DisplayObject
The default background skin to display behind the tabs.
The following example passes a bitmap for the tab bar to use as a background skin:
tabBar.backgroundSkin = new Bitmap(bitmapData);
1.0.0
.See also:
customTabVariant:String
A custom variant to set on all tabs, instead of
TabBar.CHILD_VARIANT_TAB
.
The customTabVariant
will be not be used if the result of
tabRecycler.create()
already has a variant set.
1.0.0
.See also:
dataProvider:IFlatCollection<Dynamic>
The collection of data displayed by the tab bar.
Items in the collection must be class instances or anonymous structures. Do not add primitive values (such as strings, booleans, or numeric values) directly to the collection.
Additionally, all items in the collection must be unique object instances. Do not add the same instance to the collection more than once because a runtime exception will be thrown.
The following example passes in a data provider and tells the tabs how to interpret the data:
tabBar.dataProvider = new ArrayCollection([
{ text: "Latest Posts" },
{ text: "Profile" },
{ text: "Settings" }
]);
tabBar.itemToText = (item:Dynamic) -> {
return item.text;
};
1.0.0
.See also:
disabledBackgroundSkin:DisplayObject
A background skin to display behind the tabs when the tab bar is disabled.
The following example gives the tab bar a disabled background skin:
tabBar.disabledBackgroundSkin = new Bitmap(bitmapData);
tabBar.enabled = false;
1.0.0
.See also:
layout:ILayout
The layout algorithm used to position and size the tabs.
By default, if no layout is provided by the time that the tab bar initializes, a default layout that displays items horizontally will be created.
The following example tells the tab bar to use a custom layout:
var layout = new HorizontalDistributedLayout();
layout.maxItemWidth = 300.0;
tabBar.layout = layout;
1.0.0
.tabRecycler:DisplayObjectRecycler<Dynamic, TabBarItemState, ToggleButton> = DisplayObjectRecycler.withClass(ToggleButton)
Manages tabs used by the tab bar.
In the following example, the tab bar uses a custom tab renderer class:
tabBar.tabRecycler = DisplayObjectRecycler.withClass(ToggleButton);
1.0.0
.Methods
dynamicitemToText(data:Dynamic):String
Converts an item to text to display within tab bar. By default, the
toString()
method is called to convert an item to text. This method
may be replaced to provide custom text.
For example, consider the following item:
{ text: "Example Item" }
If the TabBar
should display the text "Example Item", a custom
implementation of itemToText()
might look like this:
tabBar.itemToText = (item:Dynamic) -> {
return item.text;
};
1.0.0
.