2 Replies Latest reply on Mar 31, 2011 4:03 PM by Flex harUI

    Spark ComboBox/TextArea focus interaction

    mattrichard

      I have a ComboBox set up to change the font size of the text in a TextArea.  If I set the ComboBox to return focus to the TextArea in its change event, it causes the ComboBox to require 2 clicks to make a selection.  Here's a simple application showing the behaviour that I'm seeeing:

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                        xmlns:s="library://ns.adobe.com/flex/spark" 
                        xmlns:mx="library://ns.adobe.com/flex/mx">
           <fx:Script>     <![CDATA[
                     import flashx.textLayout.edit.IEditManager;
                     import flashx.textLayout.formats.TextLayoutFormat;
      
                     protected function sizeChange():void {
                          var format:TextLayoutFormat = new TextLayoutFormat();
                          format.fontSize = comboBox.selectedItem;
                          IEditManager(textArea.textFlow.interactionManager).applyLeafFormat(format);
                          
                          textArea.setFocus();  //Without this line, the combobox works as expected.  With it, you must click on your selection twice to close the combobox
                     }               
           ]]>     </fx:Script>
           <s:VGroup>
                <s:TextArea id="textArea" />
                <s:ComboBox id="comboBox" change="sizeChange()">
                     <s:dataProvider>
                          <s:ArrayList>
                               <fx:int>10</fx:int>
                               <fx:int>12</fx:int>
                               <fx:int>14</fx:int>
                               <fx:int>16</fx:int>
                               <fx:int>24</fx:int>
                               <fx:int>32</fx:int>
                          </s:ArrayList>
                     </s:dataProvider>
                </s:ComboBox>
           </s:VGroup>
           
      </s:Application>