标签:style http io ar color os sp on 文件
设置list的allowMultipleSelection为true就可以启用多选,支持“ctrl”多选和“shif”连选。操作方式和我们平时多选文件的方法基本一致。但这种方式在“进行切换时,会清除当前选择。”,也就是说只有按住“ctrl”的时候才能进行多选。
而我希望用户只需要点击就可以进行多选,那么要怎么做呢,看了一下api,貌似没有默认的属性可以设置。于是我决定重写list,结果发现出乎意料的简单,只需重写一个方法即可
package com.choilam.components
{
import spark.components.List;
/**
*修改list的多选模式,在运行时进行切换时,不清除当前选择
* @author clschen http://www.chenlinsheng.com/
*
*/
public class MultipleSelectList extends List
{
public function MultipleSelectList()
{
super();
}
override protected function calculateSelectedIndices(index:int, shiftKey:Boolean, ctrlKey:Boolean):Vector.
{
return super.calculateSelectedIndices(index,shiftKey,true);
}
}
}
好吧,我只是在判断把ctrlKey设成固定值true 而已~
推荐阅读:
原文:http://chenlinsheng.com/?p=1159
标签:style http io ar color os sp on 文件
原文地址:http://blog.csdn.net/clschen/article/details/41860877