Want to define one app menu , Handle it once but acrivate it from all scenes?
Here is the way
1. Define the menue modal and att as globals in the stage scene
define the handle command in the same stage scene :
now in every scene's setup function do this:
Done!!
Here is the way
1. Define the menue modal and att as globals in the stage scene
glob = {};
glob.MenuAttr = {omitDefaultItems: true};
glob.appMenuModel = {
visible: true,
items: [
Mojo.Menu.editItem, //must
{label: $L("Preferences..."), command: "do-Prefs"},
{label: $L("Help"), command: "do-about"}
]
};
define the handle command in the same stage scene :
StageAssistant.prototype.handleCommand = function(event)}
{
var currentScene = Mojo.Controller.stageController.activeScene();
if (event.type == Mojo.Event.commandEnable) {
if ((event.command == "do-Update")) {
event.preventDefault();
}
}
else {
if(event.type == Mojo.Event.command) {
switch(event.command) {
case "do-about":
Mojo.Controller.stageController.pushScene('support');
break;
case "do-Prefs":
Mojo.Log.info("do-Prefs");
Mojo.Controller.stageController.pushScene("preferences");
break;
case "do-Update":
break;
}
}
}
now in every scene's setup function do this:
this.controller.setupWidget(Mojo.Menu.appMenu, glob.MenuAttr, glob.appMenuModel);
Done!!
0 comments