You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by mark goldin <ma...@gmail.com> on 2013/10/28 18:12:29 UTC
Combobox new value
I need to have a combobox that would the following:
If I enter a value and it does not exist I want to change it back to a
value that was in the control before typing. For that I have so far this:
private var _selectedItem:Object;
addEventListener(Event.CHANGE, onChange, false, 0, true);
addEventListener(FocusEvent.FOCUS_IN, onFocusIn, false, 0, true);
private function onSelectionChange(event:Event):void
{
if (selectedIndex > -1)
{
callLater(resetValue);
}
else
{
callLater(resetValue, [false]);
}
}
private function onFocusIn(event:FocusEvent):void
{
_selectedItem = selectedItem;
}
private function resetValue(setValue:Boolean=true):void
{
if (setValue)
{
// setup selected value
}
else
// restore prev. value
selectedItem = _selectedItem;
}
A problem I am having is resetting to the previous value. I am using
callLater because without it it won't do it at all. But if I use callLater
then the code that expects newly selected value from the combo is getting
it before I am resetting it back. And it fails. Any idea how get this
working?
Thanks