FListBox: getSelectedIndex Hack

If you remove all items from an FListBox after selecting an item, it will still report that you have the 0 index selected. Obviously, this bs. After a post on the list, I found some code from a dude with a similiar problem, but no go. So, here’s the best way I know to “reset” the FListBox to go, “Oh yeah, I need to actually look at myself and see if anything is selected before returning bs information.” No, I didn’t look under the hood to find out why… it’s Friday, mofo’s.

Issuing:
<pre><code>this.list_lb.setSelectedIndex(null);</code></pre>
Will effectively refresh it, so to speak, and give you the correct index of “undefined” if nothing is selected.

4 Replies to “FListBox: getSelectedIndex Hack”

  1. It should be noted this applies to modifying the FListBox’s data provider, not the listbox itself. If you remove items from it, it correctly updates its selectedItemIndex.

  2. Just saw this on flashcoders as well.. I’ve put a QA engineer on this scenario, and we’ll make sure it doesn’t happen next release. :) Thanks for the details.

Comments are closed.