ComboBoxes allow users to select from a list or attempt to add a new value.

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/components/ComboBox.html

" the DropDownList control only lets the user select from a list of predefined 
items in the control. The ComboBox control lets the user either select a 
predefined item, or enter a new item into the prompt area. When the user enters 
a new item, the selectedIndex property is set to -3. Your application can 
recognize that a new item has been entered and, optionally, add it to the list 
of items in the control."

Adding an event handler for the combobox "changing" event.

Can do a test and prevent default if you'd like.  It will roll the selection 
back to the previous valid selection.

protected function onChanging(event:IndexChangeEvent):void
{
    if (event.newIndex == -3)
    {
        event.preventDefault();
    }
}


-Mark

-----Original Message-----
From: Maurice Amsellem (JIRA) [mailto:j...@apache.org] 
Sent: Wednesday, February 20, 2013 1:03 PM
To: dev@flex.apache.org
Subject: [jira] [Commented] (FLEX-28679) Can't type new custom selected item to 
replace existing custom selected item


    [ 
https://issues.apache.org/jira/browse/FLEX-28679?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13582380#comment-13582380
 ] 

Maurice Amsellem commented on FLEX-28679:
-----------------------------------------

Hi again, after some investigation, it seems that the simple following change 
fixes the issue:

(testing that the selection is not a custom item [selectedIndex != 
CUSTOM_SELECTED_ITEM], before copying the selection back to the input text).

ComboBox.as

override mx_internal function updateLabelDisplay(displayItem:* = 
undefined):void {

        if (textInput) {
            if (displayItem == undefined)
                displayItem = selectedItem;
            if (displayItem != null && displayItem != undefined && 
selectedIndex != CUSTOM_SELECTED_ITEM) {
                textInput.text = LabelUtil.itemToLabel(displayItem, labelField, 
labelFunction);
            }
        }
    }

What do you think? 

                
> Can't type new custom selected item to replace existing custom selected item
> ----------------------------------------------------------------------------
>
>                 Key: FLEX-28679
>                 URL: https://issues.apache.org/jira/browse/FLEX-28679
>             Project: Apache Flex
>          Issue Type: Bug
>          Components: Spark: ComboBox
>    Affects Versions: Adobe Flex SDK Previous
>         Environment: Affected OS(s): All OS Platforms
> Language Found: English
>            Reporter: Adobe JIRA
>
> Steps to reproduce:
> 1. Press in the ComboBox
> 2. Type 4
> 3. Press Enter
> 4. Press Tab
> 5. Press in the ComboBox
> 6. Type 5
> 7. Press Enter
>  
>  Actual Results:
>  ComboBox changes text back to 4
>  
>  Expected Results:
>  ComboBox should keep the text as 5
>  
>  Workaround (if any):
>  none

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to