Menu tree problem

Former Member
Former Member
I have a menu tree. In the simulator I can navigate and select in/out/up/down the tree, making multiple selections. When installed on the 920 I can only select one item, I can then scroll up and down, but if I try to select another item the menu just boots me out. My coding or bug?
  • The menu on the Moxy App works for multiple selects on the 920. I can press menu, select settings, select set graph range, and then press back twice to get back to the main view.
  • Former Member
    Former Member over 10 years ago
    Your app does the same behavior as mine, but I have more detail. You can enter into a new level, but once you exit out of that level the enter key will throw you out of the menu tree.
    Example:
    - Enter menu
    - Select settings menu
    - Back out of settings menu
    - Select About menu
    See what I mean?
  • Former Member
    Former Member over 10 years ago
    Solved. Need to return boolean from onKey() in delegate

    edit: I think I may have spoken too soon on that one. I'm sure it was working ...... for a while
  • Hi Sharkbait,

    I was already returning true from onKey in the main view delegate and from onMenuItem in the menu delegate. I added an onKey function to the menu delegate and returned true from that too. However, I still see the problem. Is there an additional onKey function that needs to return a true?
  • Former Member
    Former Member over 10 years ago
    I don't know. I just added a return at the end of my onKey function and noticed that I could use the menu as intended. It may have already been fixed due to some other tweak, but I don't know because I was in the habit of making 1 change then backing back out. Now my menus are crashing for some reason, argh.
  • Former Member
    Former Member over 10 years ago
    I don't know where your post disappeared to Travis, but in response..

    I wasn't returning at all, then I added a blanket return which I think fixed the menu usage, eg...
    class MyDelegate extends Ui.InputDelegate {

    function onKey(event)
    {
    var key = event.getKey();
    var app = App.getApp();
    if(Ui.KEY_MENU == key)
    {
    Ui.pushView(new Rez.Menus.MainMenu(), new MainMenuDelegate(), Ui.SLIDE_IMMEDIATE);
    }
    else if(Ui.KEY_DOWN == key)
    {
    Ui.switchToView(app.getNextView(), new MyDelegate(), Ui.SLIDE_IMMEDIATE);
    }
    else if(Ui.KEY_UP == key)
    {
    Ui.switchToView(app.getNextView(false), new MyDelegate(), Ui.SLIDE_IMMEDIATE);
    }
    return true;
    }
    }


    Since then I must have done something odd, because some of my menus broke. I will track it down, and I do have backups, tis just a gremlin.
  • Former Member
    Former Member over 10 years ago
    It was the straw that broke the camels back. I have a color list menu with 14 colors. Opening it crashes the app. If I shorten it down to 7 items it works, the simulator reports 58KB of 64KB usage. I don't believe the addition 7 entries is enough to consume 6KB of mem, so who knows?
  • I deleted it... Sorry. I was going to repost but I got stuck putting kids in the bath tub. I think this snippet from the MonkeyC Programmer's Guide is relevant here...

    Also, you do not have to declare the return value of a function, or even if a function returns a value, because all functions return values. You can specify the return value with a return statement, but if your function doesn’t have a return statement it will return the last value on the stack.


    It isn't clear to me in what situations we should be returning true and which we should be returning false. I ran into problems with nested menus previously, but I can't seem to find the problem code. If I remember correctly, I was returning true and I had to return false. The problem is that I think the problem came up because I was returning true from the handler for KEY_ESC in a custom menu.

    Travis
  • Former Member
    Former Member over 10 years ago
    By moving the sub menu closer to the root menu I was able to limit the memory consumed by the open menus, and can use all items again.