webOS Nation Forums > webOS apps and software > webOS development > Application Menu is Ignoring Me
Member: Baryn
at: 03:21 PM 11/19/2009
The app menu is not responding to my code at all.

Any glaring errors or omissions?

It's fairly simple:
- handleCommand (originally hand-written, this snippet is from the webOSDev forums, which could be error'd?!)
- this.appMenuModel
- setupWidget

[CODE]SceneAssistant.prototype.handleCommand = function (event) {
if( event.type == Mojo.Event.commandEnable && event.command == Mojo.Menu.helpCmd ) {
event.stopPropagation(); // kill the disable event
} else if( event.type == Mojo.Event.command ) {
switch( event.command ) {
case Mojo.Menu.helpCmd://"help"
this.controller.stageController.pushAppSupportInfoScene();
break;
default:
break;
}
}
}

SceneAssistant.prototype.setup = function() {
/* this function is for setup tasks that have to happen when the scene is first created */
/* use Mojo.View.render to render view templates and add them to the scene, if needed. */
/* setup widgets here */
this.appMenuModel = {
visible: true,
items: [
Mojo.Menu.editItem,
Mojo.Menu.helpItem
]
};

this.controller.setupWidget(
Mojo.Menu.appMenu,
this.attributes = { omitDefaultItems: true },
this.appMenuModel
);[/CODE]

Please PreCentral, you're my only hope.
Reply
Member: Baryn
at: 07:25 PM 11/19/2009
Update!

appinfo.json possessed a syntax error. >_<

So, appinfo.json can break your app menu. Remember that!
Reply
Member: Laxidasical
at: 01:55 AM 11/20/2009
Can you PLEASE tell me what your syntax error was??? I've been in app menu hell for 3 days now -> http://forums.precentral.net/web-os-...assistant.html
Reply
Member: Laxidasical
at: 02:01 AM 11/20/2009
OH MY GOD!!! I just figured out my problem thanks to you!!! Here is my appinfo.json file...

[CODE]{
"id": "com.mojackllc.mojack",
"title": "MoJack",
"version": "1.0.0",
"vendor": "MoJack, LLC",
"copyright": "&copy; Copyright 2009 MoJack, LLC",
"type": "web",
"main": "index.html",
"icon": "icon.png",
"theme": "light",
"noDeprecatedStyles": true,
"noWindow": true
}[/CODE]

Notice in "copyright" that there is a comma between my company name and LLC. THAT was breaking my menus!!! Who would have thunk it???? The REALLY odd thing...I left the comma in under "vendor" (by accident) and it works fine!!!

I'm giving you a free copy of my app/subscription when it launches!!!! (as well as a few others who helped be debug!!! PM me...)
Reply
Member: Baryn
at: 02:08 PM 11/21/2009
Originally Posted by Laxidasical:
OH MY GOD!!! I just figured out my problem thanks to you!!! Here is my appinfo.json file...

[CODE]{
"id": "com.mojackllc.mojack",
"title": "MoJack",
"version": "1.0.0",
"vendor": "MoJack, LLC",
"copyright": "&copy; Copyright 2009 MoJack, LLC",
"type": "web",
"main": "index.html",
"icon": "icon.png",
"theme": "light",
"noDeprecatedStyles": true,
"noWindow": true
}[/CODE]

Notice in "copyright" that there is a comma between my company name and LLC. THAT was breaking my menus!!! Who would have thunk it???? The REALLY odd thing...I left the comma in under "vendor" (by accident) and it works fine!!!

I'm giving you a free copy of my app/subscription when it launches!!!! (as well as a few others who helped be debug!!! PM me...)
My problem was similar. I left out a comma between properties. ARG!
Reply
Member: Laxidasical
at: 03:13 PM 11/21/2009
Originally Posted by Baryn:
My problem was similar. I left out a comma between properties. ARG!
I would have thought that prevented the app from loading at all, not just break the menus.
Reply
Member: retsamhgiht
at: 08:57 PM 12/05/2009
Lax:

I'm having the exact same issue. To try to troubleshoot, I borrowed your code (sorry!). My app consists of an app-assistant.js, and severaly scenes launched from the app-assistant. (It's a background app that requires a banner, so I don't believe a stage assistant woulda done the trick).

Here's what I've got.

[CODE]
AppAssistant.prototype.setup = function(){
MoJack = {}

}

AppAssistant.prototype.handleLaunch = function (launchParams) {

// MENU INITIALIZATION:

MoJack.menuAttributes = {omitDefaultItems: true};

MoJack.menuModel =
{
visible: true,
items:
[
Mojo.Menu.editItem,
{label: 'About MoJack...', command: 'do-aboutMoJack'}
]
};
...
var stageArguments = {name: "firstuse", lightweight: true };
this.controller.createStageWithCallback(stageArguments, pushMainScene, "firstuse");
[/CODE]

And then in firstUse.js I've tried both

[CODE]
this.controller.setupWidget(Mojo.Menu.appMenu, MoJack.menuAttributes, MoJack.menuModel);
[/CODE]

and

[CODE]
appController = Mojo.Controller.getAppController();
appController.setupWidget(Mojo.Menu.appMenu, MoJack.menuAttributes, MoJack.menuModel);
[/CODE]

The second option actually gave me an error about setupWidget() not being part of that object.

I'm lost and frustrated... see anything I'm missing?

My appinfo.json is squeaky clean - I even took all spaces (and commas) out of every attribute value.
Reply
Member: Laxidasical
at: 06:55 AM 12/06/2009
Hello retsamhgiht,

A few things...

1) In your first code block you are setting the menuAttributes and menuModel in your handleLaunch command. Instead set it up in the initialization or setup function of the app assistant.

2) Setup the widget as normal (without calling the appController)...
[CODE]this.controller.setupWidget(Mojo.Menu.appMenu, MoJack.menuAttributes, MoJack.menuModel);[/CODE]

3) I'd replace "MoJack" with something else more fitting for your particular app (can be anything). That is the name of my app, so I used it as my global namespace.
Reply

webOS Nation Forums > webOS apps and software > webOS development > Application Menu is Ignoring Me