views:

28

answers:

2

Dear all,

I have done an ovveride of the standard TextInput component
In this component I have :

addEventListener( FocusEvent.FOCUS_OUT, handleFocusOut ); 
  • My method is trigerred when the field loose focus for another field (nice)
  • Problem : It is trigerred alose when the whole flex application lose focus (when my field has the current focus inside my form)

Questions :

  • What have I done wrong ?
  • Is there a way to avoid doing stuff when it is a application-focusout-event ?

Regards

A: 

I am not sure why this is behaving this way. But one solution might be to have an eventListener for FOCUS_OUT event at the application level and call stopImmediatePropagation().

Ravi Gummadi
A: 

Thanks for your help !
Here is what I have done in my component (textinput child)

Add two event handler :
- addEventListener( Event.ACTIVATE, handleEventActivate );
- addEventListener( Event.DEACTIVATE, handleEventDeActivate );

They update the internal field _isApplicationActive
I handle the focusOut event :
addEventListener( FocusEvent.FOCUS_OUT, handleFocusOut );
in the method I have
if (!_isApplicationActive) { event.stopImmediatePropagation(); }

With this my focusOut handling functions are not called when the app is deactivated Because => DECACTIVATE events are called before FocusOut events !

CC
stopImmediatePropagation cause minor problems on the inputtext : you need to click in it to regain the blue focus border (switching back to the application is not enough)
CC