Jach's personal blog

(Largely containing a mind-dump to myselves: past, present, and future)
Current favorite quote: "Supposedly smart people are weirdly ignorant of Bayes' Rule." William B Vogt, 2010

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:

Back to the top

jojon August 02, 2011 08:48:40 PM verry useful tips thanks a lot
Back to the first comment

Comment using the form below

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

Your Comment:

LaTeX allowed in comments, use $$\$\$...\$\$$$ to wrap inline and $$[math]...[/math]$$ to wrap blocks.