In FLEX, How can you stop ENTER Key from my Alert being caught by the control that initiated the Al
Posted
by WeeJavaDude
on Stack Overflow
See other posts from Stack Overflow
or by WeeJavaDude
Published on 2010-04-29T21:24:42Z
Indexed on
2010/04/29
21:27 UTC
Read the original article
Hit count: 241
I am having an issue where I show an AlertBox message when the user hits ENTER and the focus is in a text area. The pop up works fine, but when the user hits enter the Alert closes as expected, but the TextArea listener receives the ENTER event from the Alert and pops the dialog up again. I have tried a number of ways to catch and eat the event but so far I have not been lucky. Is there way to accomplish this?
public function init():void
{
myTextInput.addEventListener(KeyboardEvent.KEY_UP, handleKeyStrokes);
}
public function handleKeyStrokes(evt:KeyboardEvent):void
{
if(evt.keyCode == Keyboard.ENTER)
{
myAlert = Alert.show("This is a test and only a test", "Title", 4, null, alertCallBack);
}
}
<mx:TextInput id="myTextInput"
left="600" top="10">
</mx:TextInput>
© Stack Overflow or respective owner