I'm creating a custom manager, and I'm baffled by why my focus handling doesn't work. Rather than post the entire program, I've written a quick test app that baffles me as well. Why doesn't this application produce a dialog? It looks like the nextFocus() method never gets called. Please help!
Code:
package FocusTest;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.system.*;
class FocusTest extends UiApplication{
public static void main(String args[]){
FocusTest theApp = new FocusTest();
theApp.enterEventDispatcher();
}
FocusTest() {
pushScreen(new FocusTestMainScreen());
}
}
class FocusTestMainScreen extends MainScreen{
VerticalFieldManager vfm;
FocusTestMainScreen(){
super();
vfm = new VerticalFieldManager(){
protected int nextFocus(int direction, boolean alt){
Dialog.alert("Focus change!");
return super.nextFocus(direction,alt);
}
}; //THIS NEVER GETS CALLED!?
vfm.add(new LabelField("Hello",Field.FOCUSABLE));
vfm.add(new LabelField("world!",Field.FOCUSABLE));
add(vfm);
}
}