| Package | feathers.core |
| Class | public class ToggleGroup |
| Inheritance | ToggleGroup starling.events.EventDispatcher |
| Product Version : | Feathers 1.0.0 |
See also
| Property | Defined By | ||
|---|---|---|---|
| isSelectionRequired : Boolean
Determines if the user can deselect the currently selected item or
not. | ToggleGroup | ||
| numItems : int [read-only]
The number of items added to the group. | ToggleGroup | ||
| selectedIndex : int
The index of the currently selected toggle. | ToggleGroup | ||
| selectedItem : IToggle
The currently selected toggle. | ToggleGroup | ||
| Method | Defined By | ||
|---|---|---|---|
Constructor. | ToggleGroup | ||
Adds a toggle to the group. | ToggleGroup | ||
Returns the item at the specified index. | ToggleGroup | ||
getItemIndex(item:IToggle):int
Returns the index of the specified item. | ToggleGroup | ||
Determines if the group includes the specified item. | ToggleGroup | ||
removeAllItems():void
Removes all toggles from the group. | ToggleGroup | ||
removeItem(item:IToggle):void
Removes a toggle from the group. | ToggleGroup | ||
setItemIndex(item:IToggle, index:int):void
Changes the index of a specified item. | ToggleGroup | ||
| Event | Summary | Defined By | ||
|---|---|---|---|---|
| Dispatched when the selection changes. | ToggleGroup | |||
| isSelectionRequired | property |
isSelectionRequired:Boolean
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 isSelectionRequired is set to true
and 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.isSelectionRequired = false;
The default value is true.
public function get isSelectionRequired():Boolean public function set isSelectionRequired(value:Boolean):void| numItems | property |
numItems:int [read-only] The number of items added to the group.
public function get numItems():int| selectedIndex | property |
selectedIndex:intThe index of the currently selected toggle.
In the following example, the selected index is changed:
group.selectedIndex = 2;
The default value is -1.
public function get selectedIndex():int public function set selectedIndex(value:int):void| selectedItem | property |
selectedItem:IToggleThe currently selected toggle.
In the following example, the selected item is changed:
group.selectedItem = radio;
The default value is null.
public function get selectedItem():IToggle public function set selectedItem(value:IToggle):void| ToggleGroup | () | Constructor |
public function ToggleGroup()Constructor.
| addItem | () | method |
public function addItem(item:IToggle):void
Adds a toggle to the group. If it is the first item added to the
group, and isSelectionRequired is true, it
will be selected automatically.
In the following example, an item is added to the toggle group:
group.addItem( radio );
Parameters
item:IToggle |
| getItemAt | () | method |
public function 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 );
Parameters
index:int |
IToggle |
See also
| getItemIndex | () | method |
public function 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 );
Parameters
item:IToggle |
int |
| hasItem | () | method |
public function hasItem(item:IToggle):BooleanDetermines 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
}Parameters
item:IToggle |
Boolean |
| removeAllItems | () | method |
public function removeAllItems():voidRemoves all toggles from the group. No item will be selected.
In the following example, all items are removed from the toggle group:
group.removeAllItems();
| removeItem | () | method |
public function removeItem(item:IToggle):void
Removes a toggle from the group. If the item being removed is
selected and isSelectionRequired is true,
the final item will be selected. If isSelectionRequired
is false instead, no item will be selected.
In the following example, an item is removed from the toggle group:
group.removeItem( radio );
Parameters
item:IToggle |
| setItemIndex | () | method |
public function 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 );
Parameters
item:IToggle | |
index:int |
| change | Event |
starling.events.Eventstarling.events.Event.CHANGEDispatched when the selection changes.
The properties of the event object have the following values:
| Property | Value |
|---|---|
bubbles | false |
currentTarget | The Object that defines the
event listener that handles the event. For example, if you use
myButton.addEventListener() to register an event listener,
myButton is the value of the currentTarget. |
data | null |
target | The Object that dispatched the event;
it is not always the Object listening for the event. Use the
currentTarget property to always access the Object
listening for the event. |