I have a (hopefully) quick question. I've got some stepper boxes. Though really this could apply to any interactive component. I want the selected box to lose focus when when I click anywhere else ( stage included ). Is there an easy way to do this? I can't seem to find an effective way to make it lose focus.
A:
Perhaps you should check out FocusManager.hideFocus()
.
Maybe tie it into the focusOut event of your UIComponent.
clownbaby
2010-08-24 01:30:08
Maybe I don't understand, but I'm not just interested in hiding the indicator. If I hide it and it's still actually selected, then other interactions like hitting the up and down arrows will cause a stepper to increment or decrement. I want to deselect any selected components.
grey
2010-08-24 01:43:22
A:
So here's the solution I've come up with that works very well. I have a function called add()
which has been assigned to applicationComplete
. In that function I include:
this.skin.addEventListener( MouseEvent.MOUSE_UP, loseFocus );
Which calls:
private function loseFocus( e : MouseEvent ) : void
{
if ( e.eventPhase == EventPhase.AT_TARGET )
{
this.focusManager.deactivate();
}
}
Simple enough, and does what I was looking for. "Phase" filter is necessary to keep other components from registering the clicks.
As an important note: this.skin
needs to be the event target. The stage is never exposed to the mouse in a Flex application.
If someone has a better solution, please suggest one!
grey
2010-08-24 02:17:04