Flex Tip: ComboBox Events(New tag "tips". I'll probably be posting a lot of little tips for various things I pick up that I didn't find immediately from Googling.)
ComboBoxes in Flex have several useful events, the most used I believe are open, close, change. But one is lacking: itemClick. There is a difference between: opening a ComboBox then clicking outside or on the ComboBox itself to close it, and opening a ComboBox then clicking an item, even if it's the same one as before.
Fortunately Flex provides a way to detect this difference. The "close" event fires a DropdownEvent which has a "triggerEvent" member, which will be null when the item was clicked, will be a buttonDown event when the user closes with the ComboBox itself, and will be a mouseDownOutside event when the user clicks somewhere else. So simply return when the triggerEvent != null, and you have an itemClick feature. Edit: After some tests it appears that this technique isn't foolproof! Edit 2: My hack was to grab this.contentX and this.contentY and constrain them that way. Not very good.
Posted on 2010-08-09 by Jach
Tags: flex, programming, tips
Trackback URL: https://www.thejach.com/view/2010/8/flex_tip_combobox_events
jojon August 02, 2011 08:48:40 PM verry useful tips thanks a lot