0

It is possible to Simulate a Tab Key when another key is pressed? I'm looking to do exactly the same, but with the DOWN & ENTER Key.

I know about the onKeyDown function. I'm trying this but it doesn't work.

private function onKeyDown( e:KeyboardEvent ) :void
            {
                if( e.keyCode == Keyboard.DOWN )
                {
                    (e.currentTarget as TextInput).dispatchEvent(new KeyboardEvent(KeyboardEvent.KEY_DOWN, true, false, 0, Keyboard.TAB));
                }
            }

I know tab works differently, I saw it in Here but still not idea.

Any help would be appreciated.

Thanks in advance.

1
  • have you tried it on the keyup event. Keydown fires first, and then keyup last. Jan 27, 2012 at 6:33

2 Answers 2

3

I resolved it like this. Hope this helps somebody else later.

private function onKeyDown( e:KeyboardEvent ) :void
            {
                if( e.keyCode == Keyboard.DOWN || e.keyCode == Keyboard.ENTER)
                {                   
                    focusManager.getNextFocusManagerComponent().setFocus();

                }
                if(e.keyCode == Keyboard.UP)
                {
                    focusManager.getNextFocusManagerComponent(true).setFocus();
                }
            }

In Flash, focusManager by itself may be undefined in that context. Change to: evt.currentTarget.focusManager.getNextFocusManagerComponent().setFocus();

0
-1

Try to put tabbing component in array, then change focus manually with:

stage.focus = myComp;

or

stage.focus = myComps[currentCompOrderNumber+1];
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.