I have a start of a custom component, that should based on the List component, 
allow for multiple selections.

Any help would be greatly appreciated, thanks

Randy

package com.somecompany.pm.Components
{
    import flash.events.Event;
    import flash.events.KeyboardEvent;
    
    import spark.components.DropDownList;
    
    public class MultiDropDownList extends DropDownList
    {
        
        private var _ctrlKey:Boolean = false;
        private var _selectedIndices:Vector.<int>;
        private var _selectedItems:Vector.<Object>
        
        public function MultiDropDownList() {
            allowMultipleSelection = true;
            super();
        }
        
        override public function closeDropDown(commit:Boolean):void{
            if (!ctrlKey)
                super.closeDropDown(true);
        } 
        
        override protected function keyDownHandler(event:KeyboardEvent):void {
            super.keyDownHandler(event);
            ctrlKey = event.ctrlKey;
            
            if (ctrlKey)
                allowMultipleSelection = true;
        }
        
        override protected function keyUpHandler(event:KeyboardEvent):void {
            super.keyUpHandler(event);
            ctrlKey = event.ctrlKey;
            
            if (!ctrlKey) {
                closeDropDown(false);
                dispatchEvent(new Event("change",true));
            }
        }
        
        override public function set selectedItems( value:Vector.<Object>):void 
{
            _selectedItems = value;
        }
        
        [Bindable(event="change")]
        override public function get selectedItems():Vector.<Object> {
            return _selectedItems;
        }
        
        override public function set selectedIndices(value:Vector.<int>):void {
            _selectedIndices = value;
        }
        
        [Bindable(event="change")]
        override public function get selectedIndices():Vector.<int> {
            return _selectedIndices;        
        }


        public function get ctrlKey():Boolean {
            return _ctrlKey;
        }

        public function set ctrlKey(value:Boolean):void  {
            _ctrlKey = value;
        }

    }
}

Reply via email to