Skip navigation
wbailey4
Currently Being Moderated

Flex 3 ComboBox Not Firing Change Event

Aug 9, 2011 10:47 AM

I have run into a peculiar behavior with the Flex 3 ComboBox. If you have a combo box that initially defaults to no item selected and a required validator, the behavior is incorrect given one particular set of user actions. See the below code which is a minimal application I came up with the reproduce the problem.

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600">
   
    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;
           
            private function boxChanged(event:Event):void {
                Alert.show("selection changed");
            }
        ]]>
    </mx:Script>
   
    <mx:Validator source="{box}" property="text" required="true"/>
   
    <mx:VBox>
       
        <mx:TextInput/>
       
        <mx:ComboBox id="box" change="boxChanged(event)" selectedIndex="-1">
            <mx:ArrayCollection>
                <mx:Object label="A1" stuff="xxxx"/>
                <mx:Object label="A2" stuff="xxxx"/>
                <mx:Object label="B1" stuff="xxxx"/>
                <mx:Object label="C1" stuff="xxxx"/>
                <mx:Object label="C2" stuff="xxxx"/>
            </mx:ArrayCollection>
        </mx:ComboBox>
   
    </mx:VBox>
   
</mx:Application>

 

If you use only the mouse to select an item from the combo box, it works fine. If you tab into it and use keystrokes to select an item, it works fine. However, if you click the down arrow with the mouse to display the list and then hit a key (e.g. A or B or C), it immediately selects that item in the list (normally, it just highlights the first matching entry and you have to click or hit enter to actually select it) but does not dispatch the change event. Once you have selected the item the first time, the same click and keypress combination works correctly ... it only fails the first time when the combo box doesn't have an item selected. And it only happens if there is a required validator on the field ... if you remove the validator, it works correctly.

 

Any ideas what is going on? And any suggestions for a workaround that achieves the same result but bypasses this issue (which appears to me to be a bug in the ComboBox control)? Upgrading to a newer version, sadly, is not an option for us at this time. Thanks.

 
Replies
  • Currently Being Moderated
    Feb 1, 2012 6:18 AM   in reply to wbailey4

    Hi wbailey4,

     

    i have a flex 3 project someone developed it and he wirte the code such as the below example:

    <mx:FormItem

                id="providerItem" width="100%"

                label="Provider"  >

                <widget:ValueComboBox

                    id="provider"

                    dataProvider="{model.logEdit.providers}"

                    value="{model.logEdit.entry.provider}"

                    change="ChangeWatcher.changeField(event)"

                    rowCount="12"

                    styleName="formField" tabIndex="1105"/>

            </mx:FormItem>

     

     

    i have similar problem as you mentioned above, but it seems he use a different approach to create the ComboBox in the mxml file, and i added the prompt property such as you mentioned befire, but unfortunately it still not working, do you have any idea !!!...

     

    thanks in advance,

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 16, 2014 6:36 AM   in reply to Wasim00

    Try using the valueComit property on mx combobox.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points