Reputation: 2317
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.
Upvotes: 0
Views: 2649
Reputation: 2317
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();
Upvotes: 3
Reputation: 1032
Try to put tabbing component in array, then change focus manually with:
stage.focus = myComp;
or
stage.focus = myComps[currentCompOrderNumber+1];
Upvotes: -1