Guest User

Untitled

a guest
Jan 20th, 2019
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using Toybox.Application;
  2. using Toybox.WatchUi;
  3.  
  4. class TestMenuAppApp extends Application.AppBase {
  5.  
  6.     function initialize() {
  7.         AppBase.initialize();
  8.     }
  9.  
  10.     // onStart() is called on application start up
  11.     function onStart(state) {
  12.     }
  13.  
  14.     // onStop() is called when your application is exiting
  15.     function onStop(state) {
  16.     }
  17.  
  18.     // Return the initial view of your application here
  19.     function getInitialView() {
  20.         return [ new TestMenuAppView(), new TestMenuAppDelegate() ];
  21.     }
  22.  
  23. }
  24.  
  25.  
  26. class TestMenuAppView extends WatchUi.View {
  27.  
  28.     function initialize() {
  29.         View.initialize();
  30.     }
  31.  
  32.     // Load your resources here
  33.     function onLayout(dc) {
  34.         //setLayout(Rez.Layouts.MainLayout(dc));
  35.     }
  36.  
  37.     // Called when this View is brought to the foreground. Restore
  38.     // the state of this View and prepare it to be shown. This includes
  39.     // loading resources into memory.
  40.     function onShow() {
  41.     }
  42.  
  43.     // Update the view
  44.     function onUpdate(dc) {
  45.         // Call the parent onUpdate function to redraw the layout
  46.         View.onUpdate(dc);
  47.     }
  48.  
  49.     // Called when this View is removed from the screen. Save the
  50.     // state of this View here. This includes freeing resources from
  51.     // memory.
  52.     function onHide() {
  53.     }
  54.  
  55. }
  56.  
  57. class TestMenuAppDelegate extends WatchUi.BehaviorDelegate {
  58.  
  59.     function initialize() {
  60.         BehaviorDelegate.initialize();
  61.     }
  62.  
  63.     function onSelect() {
  64.         var menuA = new WatchUi.Menu();
  65.         menuA.setTitle("Menu A");
  66.         menuA.addItem("Random Item A1", null);
  67.         WatchUi.pushView(menuA, new MenuADelegate(), WatchUi.SLIDE_UP);
  68.         return true;
  69.     }
  70.  
  71. }
  72.  
  73. class MenuADelegate extends WatchUi.MenuInputDelegate {
  74.  
  75.     function initialize() {
  76.         MenuInputDelegate.initialize();
  77.     }
  78.  
  79.     function onMenuItem(item) {
  80.         var menuB = new WatchUi.Menu();
  81.         menuB.setTitle("Menu B");
  82.         menuB.addItem("Random Item B1", null);
  83.         WatchUi.pushView(menuB, new MenuBDelegate(), WatchUi.SLIDE_UP);
  84.         return true;
  85.     }
  86. }
  87.  
  88. class MenuBDelegate extends WatchUi.BehaviorDelegate {
  89.  
  90.     function initialize() {
  91.         BehaviorDelegate.initialize();
  92.     }
  93.  
  94.     function onMenuItem(item) {
  95.         // do nothing
  96.     }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment