Widget is not working in glance (the glance works fine)

Hello,

I am building my first widget/glance.  It is very simple and straight forward in that it only shows the current Zulu or GMT time.  The glance itself works great, but I cannot get the widget part of it to work.  I manage to get an icon on the widget, but nothing else will display.

The full code is here...

https://github.com/FlyFrosty/ZuluGlance

My *View.mc is (minus imports):

function onLayout(dc) {

setLayout(Rez.Layouts.MainLayout(dc));

//Format Zulu Time
var zTime = Gregorian.utcInfo(Time.now(), Time.FORMAT_MEDIUM);
var zuluTime = Lang.format("$1$:$2$", [zTime.hour.format("%02d"), zTime.min.format("%02d")])+" Z";

//Draw Zulu Time
dc.setColor(Graphics.COLOR_BLUE, Graphics.COLOR_TRANSPARENT);
dc.drawText(0,dc.getHeight() / 2, Graphics.FONT_LARGE, zuluTime, Graphics.TEXT_JUSTIFY_LEFT | Graphics.TEXT_JUSTIFY_VCENTER);
}
//repeats identical at this point for the onUpdate()...
my *App.mc is (minus imports):
function getGlanceView() {
return [ new ZuluGlanceGlanceView() ];
}

function initialize() {
AppBase.initialize();
}

// Return the initial view of your application here
function getInitialView() {
return [ new ZuluGlanceView() ];
}

}

function getApp() as ZuluGlanceApp {
return Application.getApp() as ZuluGlanceApp;
}
It is rather basic which is why this is driving me nuts.
Thoughts?
  • A few things here.  for the main view, in onLayout() all you want to do is load the layout.  None of the draw stuff.

    Then in onUpdate(), your mixing dc calls and the layout. When you do the View.onUpdate(), that clears the screen and draws your layout so all you did with dc calls is lost

  • Thanks!

    Some of the code was left over from trying to troubleshoot (I just wanted something to happen in the widget).  This was kind of my first foray into the dc calls, too.  I thought the View.onUpdate actually did the dc draws, too.  That helps a lot.

    Thanks again