Problem with 'ENTER' key input and setFocus

Hi all,

I have made an input text field which takes some input from the user and then runs some application or spawns an error window, depending upon whether the user has entered a recognized string (kinda like the “run” box in windows).

It works perfectly as far as clicking on the ‘ok’ buttons is concerned. The problem happened when I tried to make it work in the case where the user presses ‘ENTER’ key instead of clicking on the button. I want the text field as well as the ‘ok’ button in the error window, both to be able respond to ‘ENTER’ key. I have added both of them to keyListeners and done the respective checking for whether they have the focus on them or not using a small function.

The problem is that both of them respond to the Same ‘ENTER’ key. Meaning thereby that the error box kinda just flashes open and closes immediately because the ‘ok’ button there takes the last key pressed as input. I am not very experienced with flash to set some sort of counter thing or anything like that to stop it from doing so.

Will really appreciate if anyone can help me out on this. Attaching a part of the code


runbox_mc.run_txt.onKeyDown = function () {
    if((Key.getCode() == Key.ENTER)&& this.isFocused()) {
       if()  do something
        if() do something
    }
}
runbox_mc.run_txt.isFocused = function () {
    if (Selection.getFocus() == targetPath (this)) {
        return true;
    } else {
        return false;
    }
}
Key.addListener(runbox_mc.run_txt);

A simliar group of functions are used for the ‘ok’ button on error box

Thanks :slight_smile: