I'm just getting started with Monkey C. I've created a test application using Visual Studio Code. I've added a View but can't open it from the main View menu.
import Toybox.Lang;
import Toybox.System;
import Toybox.WatchUi;
class LoggerMenuDelegate extends WatchUi.MenuInputDelegate {
function initialize() {
MenuInputDelegate.initialize();
}
function onMenuItem(item as Symbol) as Void {
if (item == :item_1) {
WatchUi.pushView(new LoggerGpsView(), self, WatchUi.SLIDE_UP);
System.println("item 1");
} else if (item == :item_2) {
System.println("item 2");
}
}
}
LoggerGpsView.mc
import Toybox.Graphics;
import Toybox.WatchUi;
class LoggerGpsView extends WatchUi.View {
function initialize() {
View.initialize();
}
// Load your resources here
function onLayout(dc as Dc) as Void {
setLayout(Rez.Layouts.GpsLayout(dc));
}
// Called when this View is brought to the foreground. Restore
// the state of this View and prepare it to be shown. This includes
// loading resources into memory.
function onShow() as Void {
}
// Update the view
function onUpdate(dc as Dc) as Void {
// Call the parent onUpdate function to redraw the layout
View.onUpdate(dc);
}
// Called when this View is removed from the screen. Save the
// state of this View here. This includes freeing resources from
// memory.
function onHide() as Void {
}
}