TheJach.com

A blog about the going-ons of Jach's mind

Largely a mind-dump to myselves, past, present, and future

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

Permalink: http://www.thejach.com/view/id/118

Trackback URL: http://www.thejach.com/view/2010/8/flex_tip_combobox_events

Back to the top

jojon 02 August 2011 10:48:40 PM
verry useful tips thanks a lot
Comment using the form below

(Only if you want to be notified of further responses, never displayed.)

Your Comment: