In Flex, how can one set the TextInput to "unselected" (which mean not only focus is out but also, that if you text on your keyboard, the TextInput won't be changed) on the event of pressing the Enter key? I know how to change the component that has the focus using the FocusManager, but I don't want to change the component that has focus, I just want this one component not to be selected.
+1
A:
I'm more of an AS3 dev, so I'm not sure if this works 100% in Flex, but you could use preventDefault() on the key handler and set the stage's focus to null.
textinput.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
protected function keyDownHandler(event:KeyboardEvent):void {
if (event.keyCode == Keyboard.ENTER) {
event.preventDefault();
stage.focus = null;
}
}
destroytoday
2010-01-03 15:59:36