Модераторы: SoWa
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> Combobox переписал. не найду ошибки арея 
:(
    Опции темы
locust19
Дата 21.5.2010, 13:49 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 56
Регистрация: 25.11.2009

Репутация: нет
Всего: нет



Переписал функции combobox для мультивыбора, должно всегда выдавать ареем.. если больше 1 элемента выберешь будет мне арей. если 1 то ни стринг ни бог его знает что.. не могу достать и сообразить, помогите пожалуйста, как исправить?


определенно решение лежит тут
Код

        /**
         * 'selectedItems' Setter
         **/
        public function set selectedItems( value:Array ):void
        {
            if( this.dropdown )
            {
                this.dropdown.selectedItems = value;
            }
        }


        /**
         * 'selectedItems' Getter
         **/
        [Bindable("change")]
        public function get selectedItems( ) : Array
        
        {
            if ( this.dropdown )
                return this.dropdown.selectedItems
            else
                return null;
        }


        /**
         * 'selectedIndices' Setter
         **/
        public function set selectedIndices( value:Array ) : void
        {
            if ( this.dropdown )
            {
                this.dropdown.selectedIndices = value;
            }
        }


        /**
         * 'selectedIndices' Getter
         **/
        [Bindable("change")]
        public function get selectedIndices( ) : Array
        {
            if ( this.dropdown )
                return this.dropdown.selectedIndices;
            else
                return null;
        }
}


Код

        package
{
    import flash.events.Event;
    import flash.events.KeyboardEvent;
    
    import mx.controls.ComboBox;
    import mx.events.ListEvent;

    public class MultiSelectComboBox extends ComboBox
    {
        
        private var ctrlKeyPressed:Boolean = false; //Control Key Pressed
        
        /**
         * This function checks whether the CtrlKey is pressed.
         * If CtrlKey is pressed then, 
         *                        multiple selection is enabled for the ComboBox dropdown.
         **/
        override protected function keyDownHandler( event:KeyboardEvent ):void
        {
            super.keyDownHandler( event );
            
            this.ctrlKeyPressed = event.ctrlKey;
            
            if( this.ctrlKeyPressed == true ) 
            {
                dropdown.allowMultipleSelection = true;
            }
        }
        
        /**
         * This function prevents the ComboBox from closing if CtrlKey is pressed
         * Else it fires a Change event to update selectedItems array on close  
         * 
         * If CtrlKey is not pressed then, 
         *                                ComboBox dropdown is closed and change event is dispatched.
         * 
         * 'dropdown' in a ComboBox is a List component
         **/
        override protected function keyUpHandler( event:KeyboardEvent ):void
        {
            super.keyUpHandler( event );
            this.ctrlKeyPressed = event.ctrlKey;
            
            if ( this.ctrlKeyPressed == false ) 
            {
                this.close(); 
                var changeEvent:ListEvent = new ListEvent( ListEvent.CHANGE );
                this.dispatchEvent( changeEvent );
                this.selectedIndex = -1;
            }
        }
        
        /**
         * This function prevents the ComboBox from closing if CtrlKey is pressed on a Close Event
         **/
        override public function close( trigger:Event=null ):void
        {
            if( this.ctrlKeyPressed == false )
            {
                super.close( trigger );
                this.selectedIndex = -1;
            }
        }
        
        
        /**
         * 'selectedItems' Setter
         **/
        public function set selectedItems( value:Array ):void
        {
            if( this.dropdown )
            {
                this.dropdown.selectedItems = value;
            }
        }


        /**
         * 'selectedItems' Getter
         **/
        [Bindable("change")]
        public function get selectedItems( ) : Array
        
        {
            if ( this.dropdown )
                return this.dropdown.selectedItems
            else
                return null;
        }


        /**
         * 'selectedIndices' Setter
         **/
        public function set selectedIndices( value:Array ) : void
        {
            if ( this.dropdown )
            {
                this.dropdown.selectedIndices = value;
            }
        }


        /**
         * 'selectedIndices' Getter
         **/
        [Bindable("change")]
        public function get selectedIndices( ) : Array
        {
            if ( this.dropdown )
                return this.dropdown.selectedIndices;
            else
                return null;
        }
        
        /**
         * 'MultiSelectComboBox' constructor
         **/        
        public function MultiSelectComboBox()
        {
            super();
        }
        
    }
}


Это сообщение отредактировал(а) locust19 - 21.5.2010, 13:51
PM MAIL   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | Flex | Следующая тема »


 




[ Время генерации скрипта: 0.1009 ]   [ Использовано запросов: 22 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.