class ButtonBar
package feathers.controls
extends FeathersControl › MeasureSprite › ValidatingSprite
A grouping of buttons.
The following example sets the data provider, tells the buttons how to interpret the data, and listens for when a button is triggered:
var buttonBar = new ButtonBar();
buttonBar.dataProvider = new ArrayCollection([
{ text: "Latest Posts" },
{ text: "Profile" },
{ text: "Settings" }
]);
buttonBar.itemToText = (item:Dynamic) -> {
return item.text;
};
buttonBar.addEventListener(ButtonBarEvent.ITEM_TRIGGER, buttons_itemTriggerHandler);
this.addChild(buttonBar);
Events:
feathers.events.ButtonBarEvent.ITEM_TRIGGER | Dispatched when the user taps or clicks a button. 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_BUTTON:String = "buttonBar_button"
The variant used to style the button child components in a theme.
To override this default variant, set the
ButtonBar.customButtonVariant
property.
1.0.0
.See also:
Constructor
Variables
backgroundSkin:DisplayObject
The default background skin to display behind the buttons.
The following example passes a bitmap for the button bar to use as a background skin:
buttonBar.backgroundSkin = new Bitmap(bitmapData);
1.0.0
.See also:
buttonRecycler:DisplayObjectRecycler<Dynamic, ButtonBarItemState, Button> = DisplayObjectRecycler.withClass(Button)
Manages buttons used by the button bar.
In the following example, the button bar uses a custom button renderer class:
buttonBar.buttonRecycler = DisplayObjectRecycler.withClass(Button);
1.0.0
.customButtonVariant:String
A custom variant to set on all buttons, instead of
ButtonBar.CHILD_VARIANT_BUTTON
.
The customButtonVariant
will be not be used if the result of
buttonRecycler.create()
already has a variant set.
1.0.0
.See also:
dataProvider:IFlatCollection<Dynamic>
The collection of data displayed by the button 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 buttons how to interpret the data:
buttonBar.dataProvider = new ArrayCollection([
{ text: "Latest Posts" },
{ text: "Profile" },
{ text: "Settings" }
]);
buttonBar.itemToText = (item:Dynamic) -> {
return item.text;
};
1.0.0
.See also:
disabledBackgroundSkin:DisplayObject
A background skin to display behind the buttons when the button bar is disabled.
The following example gives the button bar a disabled background skin:
buttonBar.disabledBackgroundSkin = new Bitmap(bitmapData);
buttonBar.enabled = false;
1.0.0
.See also:
layout:ILayout
The layout algorithm used to position and size the buttons.
By default, if no layout is provided by the time that the button bar initializes, a default layout that displays items horizontally will be created.
The following example tells the button bar to use a custom layout:
var layout = new HorizontalDistributedLayout();
layout.maxItemWidth = 300.0;
buttonBar.layout = layout;
1.0.0
.Methods
dynamicitemToText(data:Dynamic):String
Converts an item to text to display within button 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 ButtonBar
should display the text "Example Item", a custom
implementation of itemToText()
might look like this:
buttonBar.itemToText = (item:Dynamic) -> {
return item.text;
};
1.0.0
.