views:

304

answers:

2

Context:
I am implementing a flex auto-suggest combobox - as the user types in each character: Consider the string 'Stackoverflow' and user input = 'st'

1) the data provider is filtered to show all items starting with 'st' 2) text is set to auto-suggest string such that the un-typed part is highlighted.

So for instance, the combobox text may contain st'ackoverflow', where 'ackoverflow' is highlighted using setSelectedIndex()

Issue:
When I hit back-space or delete, and check the 'this.text' value, I expect that the last un-highlighted character ('t' in the above case) gets deleted and the data provider is filtered to show all items starting with 's'. However the text property contains 'st', as before

Question:
what am I missing? What else can I try out?

A: 

I realized that my assumption was incorrect - when I hit backspace, the highlighted portion of the text alone should go away - I need to do some extra processing to get one extra character at the beginning to go away

crazy horse
A: 

Here is how this was implemented: Listen to the backspace key event and set a Boolean flag. Then in the List change handler, read the boolean flag and set the this.text to what you want (i.e.) with 1 char deleted beyond the beginning of the highlight. Note that you cannot immediately set the this.text in the backspace handler because the textinput control backspace handler will reset what we set.

crazy horse