I have a s:List component. I want to handle a click event to know what list item is selected. I don't see Click event in s:List. Any workarounds?
Thanks.
I know I'm late to the party here, but the simplest way to get the selected node from list in a click event is to use the currentTarget property.
function myClickHandler(event:MouseEvent):void{
Alert.show("My Var: " + event.currentTarget.selectedItem.myVar);
}
<s:List ... click="myClickHandler(event);">
...
</s:List>
see:
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7cdb.html
You can use the IndexChangeEvent.CHANGE on List http://docs.huihoo.com/flex/4/spark/events/IndexChangeEvent.html
Package spark.events Class public class IndexChangeEvent Inheritance IndexChangeEvent Event Object
Language Version: ActionScript 3.0 Product Version: Flex 4 Runtime Versions: Flash Player 10, AIR 1.5
The IndexChangeEvent class represents events that are dispatched when an index changes in a Spark component.
See also
spark.components.supportClasses.ListBase spark.components.List spark.components.ButtonBar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With