view source

Getting user typed input from and editable ComboBox

June 2nd, 2008 . by polygeek

Note: Something wonky was going on the first time I tried this and it turns out that this is very easy to do without extending the ComboBox. Lesson learned: if you really, REALLY think something should work and it doesn’t then reboot and try again.

You would think that if you make a Flex ComboBox editable then it would be easy to get the value that the user typed in, right? I mean, why else give a ComboBox a property of editable. It’s one of those things that seems so obvious that I spent an hour running through the debuger looking for the value I had typed in that I thought I must be missing something.

If I’m missing something I’d appreciate it if someone would point out to me just how you can get the value*. As it turned out it was very easy to do by extending the ComboBox and overriding the textInput_changeHandler method. As I was trying to find an obvious way to get at the data I kept thinking, “Just override the frakking ComboBox to get at the data.” I should have listened to that inner voice sooner and saved an hour of frustration.

view source

After lots of searching about the only useful post I found was this one by strikefish at UniversalMind. They’re ComboBox-lookAhead is really cool. This is where I figured out to override the textInput_changeHandler to get at the data I needed.

I’d appreciate your comments if you can think of ways to improve this approach.

*Note: guessing that if it can be done Tink will be the first to comment the solution. Don’t let me down Tink. :-)

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Digg
  • Facebook

5 Responses to “Getting user typed input from and editable ComboBox”

  1. comment number 1 by: Gareth Arch

    I just tested this out and you should be able to access what the user is typing into the combobox by

    combobox.value

    This parameter holds whatever is currently displayed in the “text” area of the combobox.

  2. comment number 2 by: polygeek

    @Gareth, I swear to the gods I tried that. Over and over. Did it just now, to the same code I was working with before and it works.

    Maybe my code had a 24-hour flu or something. :-)

  3. comment number 3 by: Tink

    [code]

    [/code]

  4. comment number 4 by: Tink

    bugger that didn’t work very well huh!

    I appreciate your confidence in me ;)

    You can use ‘text’ or ‘value’.

  5. comment number 5 by: Gareth Arch

    I feel your pain :). There have been times that something is just not working, I try everything I can think of for an hour, I ask my fellow coders for help, they stand next to me (without changing anything), I re-compile, and what do you know…it works. :)

Leave a Reply

Name

Mail (never published)

Website

- Why ask? This confirms you are a human user!

   




© Copyright 2008 polyGeek.com / Dan Florio, All Rights Reserved Except Where Explicitly Stated
Web Developement Blogs - Blog Catalog Blog Directory
M2 Websites