Multiple selection in a spark List without the control key
The spark List component in Flex 4 allows you to select multiple items when you set allowMultipleSelection to true. With this flag set you can select multiple items by using the control/command key.
If you want to have a List that allows multiple selection, but does not require the user to hold down the control key when selecting items you can subclass List and override the item_mouseDownHandler() method.
The following example demonstrates a subclass of List called CheckList that does just that:
This sample uses an item renderer function to use a different renderer based on if the item is a heading or not. You can still select these heading items, but the heading renderer doesn’t look any different when it’s selected. Examining the selectedItems property of the List will show that the heading items are actually selected. If you don’t want to allow these items to be selected check out this post.
Note: This sample requires Flex SDK 4.0.0.12800 or higher. You can get the latest SDK builds from opensource.adobe.com.
Thanks, this is extremely helpful!
Great – Glad it helped