www.webOShelp.net

Get the latest on:webOS Developers' RSS FeedwebOS Facebook page webOS Twitter Feed

Home

AppMenu

Example usage:

StageAssistant.prototype.setup = function() {
  // Setup Application Menu with an About entry
  //
  newsMenuAttr = {omitDefaultItems: true};
  newsMenuModel = {
    visible: true,
    items: [
      {label: "About News...", command: 'do-aboutNews'},
      Mojo.Menu.editItem,
      Mojo.Menu.prefsItem,
      Mojo.Menu.helpItem
    ]
  };
  this.controller.pushScene("feedList");
};

// handleCommand - Setup handlers for menus:
//
StageAssistant.prototype.handleCommand = function(event) {
  var currentScene = this.controller.activeScene();
  if(event.type == Mojo.Event.command) {
    switch(event.command) {
      case 'do-aboutNews':
        currentScene.showAlertDialog({
          onChoose: function(value) {},
          title: "News - v1.0",
          message: "Copyright 2008-2009, Palm Inc.",
          choices:[
           {label: "OK", value:""}
          ]
        });
      break;
    }
  }
};

To instantiate the menu in each scene, each scene assistant must then call:

// Setup Application Menu
this.controller.setupWidget(Mojo.Menu.appMenu, newsMenuAttr, newsMenuModel);

This code generates the following menu and dialog (when the user selects "About News..." from the menu):

mojo application menu

mojo about dialog