I set up 2 views, each with a menu that appears from the view based on a BehaviorDelegate.onMenu call. The 1st view and menu function fine on both simulator and VA HW. The 2nd view appears (as a result of a menu choice from 1st menu) and the 2nd menu will also appear (with a subsequent menu button press) on both sim and VA. However, on VA HW, the 2nd menu onItem calls are never received, though they work fine on sim.
Here's some code that shows it:
using Toybox.Application as App;
using Toybox.Graphics as Gfx;
using Toybox.System as Sys;
using Toybox.WatchUi as Ui;
class MenuTestApp extends App.AppBase {
function getInitialView() {
return [ new FirstScreenView(), new FirstScreenDelegate() ];
}
}
class FirstScreenDelegate extends Ui.BehaviorDelegate {
function onMenu() {
var mMenu = new Ui.Menu();
mMenu.addItem("1stMenu 1", :item_1a);
Ui.pushView(mMenu, new FirstMenuDelegate(), Ui.SLIDE_UP);
return true;
}
}
class FirstScreenView extends Ui.View {
function onLayout(dc) {
setLayout(null);
}
function onUpdate(dc) {
View.onUpdate(dc);
dc.setColor(Gfx.COLOR_BLACK, Gfx.COLOR_BLACK);
dc.clear();
dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_TRANSPARENT);
dc.drawText(10, 10, Gfx.FONT_MEDIUM, "1stScreen, Hit Menu", Gfx.TEXT_JUSTIFY_LEFT);
}
}
class SecondScreenDelegate extends Ui.BehaviorDelegate {
function onMenu() {
var sMenu = new Ui.Menu();
sMenu.addItem("2ndMenu 1", :item_1b);
Ui.pushView(sMenu, new SecondMenuDelegate(), Ui.SLIDE_UP);
return true;
}
}
class SecondScreenView extends Ui.View {
function onLayout(dc) {
setLayout(null);
}
function onUpdate(dc) {
View.onUpdate(dc);
dc.setColor(Gfx.COLOR_BLACK, Gfx.COLOR_BLACK);
dc.clear();
dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_TRANSPARENT);
dc.drawText(10, 10, Gfx.FONT_MEDIUM, "2ndScreen, Hit Menu", Gfx.TEXT_JUSTIFY_LEFT);
}
}
class FirstMenuDelegate extends Ui.MenuInputDelegate {
function onMenuItem(item) {
if (item == :item_1a) {
Ui.pushView(new SecondScreenView(), new SecondScreenDelegate(), Ui.SLIDE_UP);
Sys.println("1stMenu, item 1");
}
}
}
class SecondMenuDelegate extends Ui.MenuInputDelegate {
function onMenuItem(item) {
if (item == :item_1b) {
// Shows up on sim, not on VA
Sys.println("2ndMenu, item 1");
}
}
}