I have a Form with multiple TextFields. Each TextField has two Commands and an ItemCommandListener. Regardless of which TextField is selected, the ItemCommandListener.commandAction(Command, Item) method is invoked with the first TextField. Although I can go up/down and edit the different TextFields, it's as if the first TextField is always selected when it comes to executing commands.
This works in WTK, but not in microemulator. Is it a bug?
sample code:
Form form = new Form("...");
Command ok = new Command("Ok", Command.OK, 1);
Command cancel = new Command("Cancel", Command.CANCEL, 1);
ItemCommandListener l new ItemCommandListener() {
public void commandAction(Command cmd, Item item) {
// always gets called with t1, even if t2 is highlighted
}
};
I have a Form with multiple TextFields. Each TextField has two Commands and an ItemCommandListener. Regardless of which TextField is selected, the ItemCommandListener.commandAction(Command, Item) method is invoked with the first TextField. Although I can go up/down and edit the different TextFields, it's as if the first TextField is always selected when it comes to executing commands.
This works in WTK, but not in microemulator. Is it a bug?
sample code:
Form form = new Form("...");
Command ok = new Command("Ok", Command.OK, 1);
Command cancel = new Command("Cancel", Command.CANCEL, 1);
ItemCommandListener l new ItemCommandListener() {
public void commandAction(Command cmd, Item item) {
// always gets called with t1, even if t2 is highlighted
}
};
TextField t1 = new TextField(null, "abc", 10, TextField.ANY);
t1.addCommand(ok);
t1.addCommand(cancel);
t1.setItemCommandListener(l);
TextField t2 = new TextField(null, "def", 10, TextField.ANY);
t2.addCommand(ok);
t2.addCommand(cancel);
t2.setItemCommandListener(l);
Can you prepare simple MIDlet that help reproducing your problem?
Regards,
Bartek