class ToggleGroup
package feathers.core
extends EventDispatcher
implements IDataSelector<IToggle>, IIndexSelector
Controls the selection of two or more IToggle instances where only one may be selected at a time.
1.0.0
.See also:
Constructor
Variables
requireSelection:Bool
Determines if the user can deselect the currently selected item or not.
The selection may always be cleared programmatically by setting the
selected index to -1
or the selected item to null
.
If requireSelection
is set to true
, the toggle group has items that
were added previously, and there is no currently selected item, the item
at index 0
will be selected automatically.
In the following example, selection is not required:
group.requireSelection = false;
1.0.0
.selectedIndex:Int
The index of the currently selected toggle.
When the value of the selectedIndex
property changes, the component
will dispatch an event of type Event.CHANGE
.
In the following example, the selected index is changed:
group.selectedIndex = 2;
1.0.0
.See also:
openfl.events.Event.CHANGE
selectedItem:IToggle
The currently selected toggle.
When the value of the selectedItem
property changes, the component
will dispatch an event of type Event.CHANGE
.
In the following example, the selected item is changed:
group.selectedItem = radio;
1.0.0
.See also:
openfl.events.Event.CHANGE
Methods
addItem(item:IToggle):Void
Adds a toggle to the group. If it is the first item added to the group,
and requireSelection
is true
, it will be selected automatically.
In the following example, an item is added to the toggle group:
group.addItem(radio);
1.0.0
.See also:
getItemAt(index:Int):IToggle
Returns the item at the specified index. If the index is out of range,
a RangeError
will be thrown.
In the following example, an item's at a specific index is returned:
var item:IToggle = group.getItemAt(2);
1.0.0
.See also:
getItemIndex(item:IToggle):Int
Returns the index of the specified item. Result will be -1
if the item
has not been added to the group.
In the following example, an item's index is calculated:
var index:Int = group.getItemIndex(radio);
1.0.0
.hasItem(item:IToggle):Bool
Determines if the group includes the specified item.
In the following example, we check if an item is in the toggle group:
if(group.hasItem(radio))
{
// do something
}
1.0.0
.removeAllItems():Void
Removes all toggles from the group. No item will be selected.
In the following example, all items are removed from the toggle group:
group.removeAllItems();
1.0.0
.removeItem(item:IToggle):Void
Removes a toggle from the group. If the item being removed is selected
and requireSelection
is true
, the final item will be selected. If
requireSelection
is false
instead, no item will be selected.
In the following example, an item is removed from the toggle group:
group.removeItem(radio);
1.0.0
.See also:
setItemIndex(item:IToggle, index:Int):Void
Changes the index of a specified item. Throws an ArgumentError
if the
specified item hasn't already been added to this group.
In the following example, an item's index is changed:
group.setItemIndex(radio, 2);
1.0.0
.