Переписал функции 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
|