Search code examples
apache-flexcomboboxshow-hide

flex combobox hide and show down arrow


I am looking to implement a search text box as follows:

When user starts typing in and there are non-zero results, the text box will open up and display the results below it. When the user selects a result, the text box closed, but this time with a down-arrow (like a combobox) so that the user can re-open the list.

I suspect what I really need is a combobox with ability to hide/show the down arrow. How do I do this in Flex?

Thanks in advance.


Solution

  • I found out an easy way to do this:

    setStyle("arrowButtonWidth", 0);

    In my custom combobox, I set the initial width of the arrow button to 0.

    Then in the List change event,

      addEventListener(ListEvent.CHANGE, changeHandler);
    

    if the size of the dataprovider is greater than 1, the arrow width is set back to (say) 20

      setStyle("arrowButtonWidth", 20);
    

    This approach is much simpler than the above approaches. If you know any pitfall of my approach, please share.