Provides a selection from a collection of items.

Available since

1.0.0

.

Variables

selectedIndex:Int

The index of the currently selected item in the item collection. Returns -1 if no item is selected.

The following example selects an item by passing its index to the selectedIndex property:

control.selectedIndex = 2;

The following example clears the currently selected index:

control.selectedIndex = -1;

The following example listens for when the selection of a ListView component changes, and it requests the new selected index:

var listView = new ListView();
function changeHandler(event:Event):Void
{
	var listView = cast(event.currentTarget, ListView);
	trace("selection change: " + listView.selectedIndex);
}
listView.addEventListener(Event.CHANGE, changeHandler);
Available since

1.0.0

.

See:

selectedItem:T

The currently selected item. Returns null if no item is selected.

The following example changes the selected item:

list.selectedItem = newItem;

Note: If the new item is not in the item collection, the selected item will be set to null instead.

The following example clears the currently selected item:

control.selectedItem = null;

The following example listens for when the selection of a ListView component changes, and it requests the new selected index:

var listView = new ListView();
function changeHandler(event:Event):Void
{
	var listView = cast(event.currentTarget, ListView);
	var text = listView.itemToText(listView.selectedItem);
	trace("selection change: " + text);
}
listView.addEventListener(Event.CHANGE, changeHandler);
Available since

1.0.0

.

See: