Do Menus Work?

Former Member
Former Member
I'm looking through the docs and I think a menu might be the right thing for a certain part of my app. I at least wanted to try them out, but the docs are completely incorrect and I've gotten far enough that I think I'm blocked.

Let's start with the Menu section from here: http://developer.garmin.com/connect-iq/developer-tools/user-interface/

xml resource config:

The docs show:

<menu name="MainMenu">
<menu-item id="item_1" handlerMethod="menu_handler_method_1">Item 1</menu-item>
<menu-item id="item_2" handlerMethod="menu_handler_method_2">Item 2</menu-item>
</menu>


This is incorrect. "name" in the "menu" element should actually be "id", and the above won't even compile.

accessing the menu object

The docs say:

class MyClass extends Ui.Page {
var menu;
function initialize() {
menu = new MainMenu(self);
}
}


This also doesn't work. After grepping the debug symbols, I realized that the following code will allow you to access the menu object:

...
menu = Rez.Menus.MainMenu;
...


what next?Once I get here, I try to call

menu.openMenu(Ui);


like the docs instruct, but I get errors related to files on somebody else's computer:

Failed invoking <symbol>
Symbol Not Found Error
in onKey (source/MackSmack.mc:197)
in handleEvent (/Users/lahm/Desktop/Monkeybrains/toolchain/mbsimulator/submodules/technology/monkeybrains/virtual-machine/api/WatchUi.mb:237)


This looks like the end of the road for menus for now, and there aren't any examples of anyone actually using Rez.Menus in the samples. Anyone have any luck with these?

Speaking of which, what would a menu look like on the Fenix 3? I figured I'd just pop one up when someone pressed the start key.

Thanks!
  • Former Member
    Former Member over 10 years ago
    Are you using Eclipse? You can just create a new Connect IQ app. It will have a working menu example.
  • Former Member
    Former Member over 10 years ago
    I'm not using Eclipse, but the app that it generates does provide a good example of how to use the menu. Thank you!

    Here's the last bit of the puzzle. Calling `menu.openMenu()` is completely incorrect, as is the way in which I fetched the menu in the initializer. There was a little bit of help from the API docs from the Menu class, but not enough to get me all the way to the end. Here's how you show a menu:

    1. Define the menu in the resource list with the corrections made in the OP.
    2. Use Ui.pushView() to push the menu from Rez like so:

    Ui.pushView(new Rez.Menus.MyMenu(),
    new MeMenuInputDelegate(),
    Ui.SLIDE_LEFT);
  • The docs are out-of-date. There are sample programs that show how to use menus. The Input example might be a good place to start.

    Travis
  • I'll file a ticket to get the docs updated--it looks like this is incorrect both on the site the OP linked to and in the Programmer's Guide that ships with 1.1.0. Apologies for any confusion!
  • Former Member
    Former Member over 10 years ago
    Are the docs open sourced anywhere? It would be pretty convenient to just file a PR for this sort of stuff, or even look at open issues / bugs in the docs. At the same time, is any of MonkeyC open source?
  • Neither the documentation nor Monkey C is open source. We do have plans to implement some better bug tracking and reporting processes in the future, but right now it's all tracked internally.