Hello,
I´m having problems with exit-command disappearing from a Canvas when adding a command to it. Here´s an example midlet:
When the "Add command" is selected "Exit" disappears from the menu. But if you change the canvas back to normal mode the exit is in the right softkey.Code:package command; import javax.microedition.lcdui.Canvas; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Graphics; import javax.microedition.midlet.MIDlet; public class CommandMidlet extends MIDlet implements CommandListener { private Command exitCommand = new Command("Exit",Command.EXIT, 0); private Canvas view = new CommandCanvas(); public void startApp() { view.setCommandListener(this); view.addCommand(exitCommand); Display.getDisplay(this).setCurrent(view); } public void destroyApp(boolean b) { } public void pauseApp() { } public void commandAction(Command c, Displayable d) { if(c == exitCommand) { notifyDestroyed(); } } private class CommandCanvas extends Canvas implements CommandListener { private CommandListener listener = null; private Command addCommand = new Command("Add command",Command.SCREEN,1); private Command addedCommand = new Command("Added command",Command.SCREEN,2); private Command fullScreenCommand = new Command("Toggle fullscreen",Command.SCREEN, 0); private boolean fullscreen = true; public CommandCanvas() { setFullScreenMode(fullscreen); super.setCommandListener(this); addCommand(addCommand); addCommand(fullScreenCommand); } protected void paint(Graphics g) { g.drawString("Select command", 0, 0, Graphics.TOP|Graphics.LEFT); } public void commandAction(Command c, Displayable d) { if(c == addCommand) { addCommand(addedCommand); } else if(c == fullScreenCommand) { fullscreen = !fullscreen; setFullScreenMode(fullscreen); } else if(listener != null) { listener.commandAction(c, this); } } public void setCommandListener(CommandListener l) { listener = l; } } }
Using some other Command type than EXIT or BACK or handling all the commands in the canvas class works. This happens in S60 3rd edition emulator and S60 3rd edition phones but not in S60 3rd editon FP1 simulator.
Any ideas why this is happening?

Reply With Quote

