Example usage:
StoryListAssistant.prototype.setup = function() { // Setup scene header with feed title and next/previous feed buttons // If first feed, suppress Previous menu; if last feed, suppress Next menu // var feedMenuPrev = {}; var feedMenuNext = {}; if (this.feedIndex > 0) { feedMenuPrev = { icon: 'back', command: 'do-feedPrevious' }; } else { feedMenuPrev = {icon: "", command: '', label: " "}; } if (this.feedIndex < feedList.length-1) { feedMenuNext = { iconPath: 'images/menu-icon-forward.png', command: 'do-feedNext' }; } else { feedMenuNext = {icon: "", command: '', label: " "}; } // Define the model with next and previous menu items, and a title // area for the feed title where the width is set to creating a // style header this.feedMenuModel = { visible: true, items: [{ items: [ feedMenuPrev, { label: this.feed.title, width: 210 }, feedMenuNext ] }] }; // Setup the View Menu this.controller.setupWidget(Mojo.Menu.viewMenu, { spacerHeight: 0, menuClass:'no-fade' }, this.feedMenuModel);
Here are the event handlers for the menu buttons:
// ---------------------------------------------------------------------------------- // Setup handlers for view menu StoryListAssistant.prototype.handleCommand = function(event) { if(event.type == Mojo.Event.command) { switch(event.command) { case 'do-feedNext': Mojo.Controller.stageController.swapScene("storyList", this.feedIndex+1); break; case 'do-feedPrevious': Mojo.Controller.stageController.swapScene("storyList", this.feedIndex-1); break; } } };
This code generates a menu that looks like this: