I am new to Monkey C, and I am trying to make a menu in my app that is populated with items automatically, but when the menu button is pressed a "Symbol not found error" occurs:
Error: Symbol Not Found Error Details: Could not find symbol 'mItems' Stack: - addItem() at /Users/rayburn/projects/toolchain5/mbsimulator/submodules/technology/monkeybrains/virtual-machine/api/WatchUi.mb:2352 0x30003ed4 - initialize() at C:\git\MyRepo\source\MyMenuDelegate.mc:16 0x1000084c - onMenu() at C:\git\MyRepo\source\MyDelegate.mc:19 0x10000790 - handleEvent() at /Users/rayburn/projects/toolchain5/mbsimulator/submodules/technology/monkeybrains/virtual-machine/api/WatchUi.mb:1240 0x30003891
Here is the code:
using Toybox.WatchUi; using Toybox.System; using Toybox.Application; class MyMenuDelegate extends WatchUi.Menu2InputDelegate { function initialize() { Menu2InputDelegate.initialize(); var labelsArr = getLabels(); var n = labelsArr.size(); for (var i = 0; i < n; ++i) { var menuItem = new WatchUi.MenuItem(labelsArr[i], null, "" + i, null); var menu = Rez.Menus.MainMenu; menu.addItem(menuItem); System.println("adding " + labelsArr[i]); } } function onSelect(item) { System.println(item.getId()); Application.getApp().setProperty("selected", item.getId().toNumber()); } function getLabels() { ... //Returns an array of String values with the menu items that should be added } }
Line 16 is the line where addItem() is called.
Any help would be appreciated!