×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    50

    options menu in FullCanvas?

    Hi,
    In midlet, when the screen is Canvas, there is "options". When click the left softkey,

    the menu in options is open.
    But if the screen is FullCanvas, Can we do like that also? I mean , the screen is

    FullCanvas, there is no "options" in screen of course. But when I click the left

    softkey, I still want to open the menu of options. Can we do that in Midlet?

  2. #2
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Helsinki.FI
    Posts
    112

    RE: options menu in FullCanvas?

    Hi xrsu,

    it is possible to invoke any displayable items from the FullCanvas by implementing the specific function in the softkeys (or any other keys, but in Nokia way this is being done with softkeys) as you can see from the example below. Hope this helps you out.


    Excerpts from class GameFullCanvas that utilizes the Nokia UI API FullCanvas class:

    public class GameFullCanvas extends FullCanvas implements Runnable {
    private GameMIDlet parent = null;
    private MainMenu menu = null;

    public GameFullCanvas(GameMIDlet parent, MainMenu menu) {
    this.parent = parent;
    this.menu = menu;
    start();
    }

    synchronized void start() {
    tickThread = new Thread(this);
    tickThread.start();
    }

    synchronized void stop() {
    tickThread = null;
    }

    public void run() {
    // this is where your game loop runs
    }

    public void paint(Graphics g) {
    // this is where your game is painted on the screen
    }

    public void keyPressed(int keyCode) {
    if (keyCode == KEY_SOFTKEY1 |keyCode == KEY_SOFTKEY2) {
    stop();
    menu.init(parent);
    parent.setDisplayable(menu);
    }

    }


    Excerpts from the class MainMenu that can be invoked from the GameFullCanvas in this case:

    public class MainMenu extends List implements CommandListener {

    private GameMIDlet parent = null;
    private GameFullCanvas game = null;

    public MainMenu(String p0, int p1, GameMIDlet parent) {
    super(p0, p1);
    init(parent);
    }

    public void init(GameMIDlet parent) {
    this.parent = parent;
    this.setCommandListener(this);
    // this is where your menu is painted
    }

    public void commandAction(Command c, Displayable d) {
    List l = (List)d;
    String selected = l.getString(l.getSelectedIndex());
    // this is where you implement the menu item actions
    }

    }


    Excerpts from the GameMIDlet class:

    public class GameMIDlet extends MIDlet {

    private Display display = null;
    private GameFullCanvas game;
    private MainMenu menu;

    public GemGameMIDlet() {
    String title = "Main Menu"
    //
    // this is just an example
    // do not hard code the text items but use some specific
    // resources class of your own that provides localized
    // texts according to the language setting of your phone
    //
    menu = new MainMenu(title, List.IMPLICIT, this);
    }

    protected void startApp() throws MIDletStateChangeException {
    if (display == null)
    display = Display.getDisplay(this);
    setDisplayable(menu);
    }

    protected void pauseApp() {
    }

    protected void destroyApp (boolean unconditional) throws MIDletStateChangeException {
    }

    public void setDisplayable(Displayable d) {
    display.setCurrent(d);
    }

    }


    Kind regards,
    Tinke / FN
    DRINK COFFEE - Do stupid things faster with more energy

  3. #3
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    50

    RE: options menu in FullCanvas?

    Hi tinkezione,
    Thank you very much for your detailed answer.
    I understand your codes here. Yes. That's the solution.

    Can I ask further about the options menu in FullCanvas?
    In your solution, the menu is extended from List. So I can say that, when click the softkey in FullCanvas, the screen is replaced by this List Menu. So I can see the options menu in current screen.
    Have you noticed that in Canvas screen? when you click the options. The menu pop up, but the whole screen is not changed. The background of the screen is still the Canvas. when you click the cancel, back to the Canvas again. No screen change there.
    OK. This is for Canvas. So I want to implement it in FullCanvas like this. Is that possible? In another word, when click the softkey, the menues pop up(not change the whole screen), but the screen background is still the image of the FullCanvas, maybe just become a little fuzzy when the menus popup.

    Can we do that in MIDlet programming? Is there some easy way to do that?

    Thank you very much.

  4. #4
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Tampere / Finland
    Posts
    201

    RE: options menu in FullCanvas?

    Hi,

    In Canvas, "Option" works as a Command and it may contain more Commmands in a pop up manu. If you click "Option", the manu will be shown on the canvas background. This is implemented by J2ME MIDP, in another word, you don't need to code "pop up" operation, it can be done automatically when you click "Option".

    Commands cannot be added to FullCanvas, It will always throw java.lang.IllegalStateException if you implement any Command in FullCanvas. So the alternative sulotion is to use SoftKeys and it's the developers' task to code the implementation of SoftKeys. In Tinke's example, a List is called when the Softkey pressed. It's quite comman to use List to show a command manu like "Options" in Canvas. List is a High Level UI inherits Screen class, which is another kind of Displayable than Canvas. That's the reason why the FullCanvas will be replaced by the List.

    From my opinion, probably it's impossible to make the "Pop up" manu in FullCanvas by using J2ME MIDP. Symbian native programming (C++) may support this implementation.

    Best Regards,

    Wang Kui / Forum Nokia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×