2
votes

I have an app where I am looking to make the enter key act like a tab key. I can easily capture the keypress event and setFocus to a textinput field. The problem is figuring out which textinput field to give focus to. I have this code


trace(this.window.focusManager);
//returns TheWindow86.focusManager

trace(this.window.focusManager.getNextFocusManagerComponent());
//returns null

//This is what I was hoping would work
this.window.focusManager.getNextFocusManagerComponent().setFocus();

The code is in a controller class and "this.window" references an instance of a nativeWindow mxml file "TheWindow.mxml". The first trace works as expected, but the second one gives null. The last line is the code that I am wanting to work.

5
What's inside your "window"? Are there any focusable controls ? - Adrian Pirvulescu
It has a good 20 - 30 text boxes and buttons. I am even calling the function from a text boxes key press event. - respectTheCode

5 Answers

0
votes

focusManager.moveFocus(FocusRequestDirection.FORWARD);

try it;

0
votes

I've got the same problem. It's clear that - this.window.focusManager.getNextFocusManagerComponent().setFocus(); - gives to you en error because - this.window.focusManager.getNextFocusManagerComponent() - returns null.

I can't realize why focusManager doesn't know what component would come next... there is the problem.

0
votes
focusManager.moveFocus(mx.events.FocusRequestDirection.FORWARD);

works well if focusManager is a property of mx.core.Application

0
votes

It seems to be a bug. I have observed it occurs around forms with defaultButtons set.

0
votes

Can you try with:

this.window.focusManager.setFocus(this.window.focusManager.getNextFocusManagerComponent());

Hope it works... if not let me know and I will try it in flex builder!