Mega Code Archive

 
Categories / Flex / Components
 

Trigger the drop down of DropDownList

<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:s="library://ns.adobe.com/flex/spark"                            >     <mx:Script>                      import mx.events.FlexEvent;                          import spark.events.IndexChangeEvent;             [Bindable]             protected var seasonLabel:String;             protected function buttonClickHandler(event:MouseEvent):void {                 myDropDown.openDropDown();             }             protected function seasonChangeHandler(event:IndexChangeEvent):void {                 seasonLabel = seasonsData.getItemAt(event.newIndex).label as String;             }                          protected function keyPressHandler(event:KeyboardEvent):void{   //              if(event.keyCode == 83 && event.altKey){                     myDropDown.setFocus();                     myDropDown.openDropDown();     //            }             }            </mx:Script>     <mx:ArrayCollection id="seasonsData">             <mx:Object label="Winter"/>             <mx:Object label="Spring"/>             <mx:Object label="Summer"/>             <mx:Object label="Fall"/>     </mx:ArrayCollection>     <mx:TextInput id="textInput" keyDown="keyPressHandler(event)"/>     <s:DropDownList id="myDropDown" dataProvider="{seasonsData}" change="seasonChangeHandler(event)"/>     <mx:Label text="{seasonLabel}"/> </mx:Application>