What needs to be changed in the code in the MenuTest sample app so the "Press the menu\nbutton to start" is bypassed and it goes directly to the Menus?
Thanks.
What needs to be changed in the code in the MenuTest sample app so the "Press the menu\nbutton to start" is bypassed and it goes directly to the Menus?
Thanks.
Using the menu2sample (I had it in my work space and menutest will be similar), in menutestview.mc. change onUpdate to push the menu (the same as you see in onMenu()) to:
public function onUpdate(dc as Dc) as Void {
// Call the parent onUpdate function to redraw the layout
//View.onUpdate(dc);
var menu = new WatchUi.Menu2({:title=>new $.DrawableMenuTitle()});
menu.addItem(new WatchUi.MenuItem("Toggles", "sublabel", "toggle", null));
menu.addItem(new WatchUi.MenuItem("Checkboxes", null, "check", null));
menu.addItem(new WatchUi.MenuItem("Icons", null, "icon", null));
menu.addItem(new WatchUi.MenuItem("Custom", null, "custom", null));
WatchUi.pushView(menu, new $.Menu2TestMenu2Delegate(), WatchUi.SLIDE_UP);
}
This pushes the menu right away.
With Menu2, in onBack() for that menu in menutestmenudelegate.mc have it do a System.exit() so the app exits when back is pressed on the main menu, like this:
public function onBack() as Void {
//WatchUi.popView(WatchUi.SLIDE_DOWN);
System.exit();
}
If you are using menu instead of menu2, you might want to add a menu item to exit. Doing this with Menu2 is a bit easier.
On some devices, you can use a native view, like menu2, as the initial view for your app.
Thanks. Got it to work and since I was using menu and not menu2, I added a 'Back' menu item that calls System.exit but it simply redisplay the menu lol. It doesn't exit the app. I'll look at changing from menu to menu2.
Hmm, even in the menu2 sample app, somehow System.exit doesn't exit the app, either being called from the delegate or the view. Don't know what I'm doing wrong.
The sample is still a watch-app, correct? You didn't change it to a widget? exit() doesn't work in widgets.
LOL, nope. I'm making a widget so that's what I changed it to. Explains why. I did manage to 'fix' it though but starting a menu as the main screen is screwed up a bit since it wants to launch the menu twice so popView doesn't work as expected. I 'hacked' it by using a global variable that keep track if the menu is displayed and only launch it once. I'm also 'hacking' the OnUpdate to display text instead of the menu. Below is the output of debugging println in the code. If you want to take a look at it, it's at https://github.com/SylvainGa/Garmin-WeeWX
Showing
Creating menu and delegate
pushing menu and delegate <- first pushView in onUpdate after it created the menu and delegate
Menu already up, skipping pushView <- This is the second pushView (on a different onUpdate) which would have also created a new set of menu and delegate
Hiding
{Selected one on the menu entry}
Showing
Displaying text
Displaying text
Displaying text
{Text is being displayed on screen instead of menu}
{Touched the screen to return to the menu}
Tap!
pushing menu and delegate
Hiding
{Pressing ESC once does nothing in the simulator but blanks the screen on the watch}
Showing
Menu already up, skipping pushView
Menu already up, skipping pushView
{Pressing ESC a second time stops the widget in both simulator and watch}
message is null in WeeWXMenuDelegate, exiting
Exiting
Menu already up, skipping pushView
Hiding
Stopping
Not sure how it would react in a button only device since ours are touch screen (Venu and VA4S) and as can be seen, the simulator behaves differently than the real device to exit.
Thanks for your help BTW :-)