11/17/2009, 03:43 AM
|
#1 (permalink) |
|
Member
![]() ![]() Join Date: Jul 2004
Location: Chicago
Posts: 574
Likes Received: 0
Thanks: 62
Thanked 60 Times in 42 Posts
|
When you setup an application menu widget in a scene and your handleCommand function is in your app-assistant.js rather than your stage-assistant.js, do you have to instantiate it with something like...
Code:
appController = Mojo.Controller.getAppController(); appController.setupWidget(Mojo.Menu.appMenu, MoJack.menuAttributes, MoJack.menuModel); Code:
this.controller.setupWidget(Mojo.Menu.appMenu, MoJack.menuAttributes, MoJack.menuModel); In my app assistant's setup function... Code:
MoJack.menuAttributes = {omitDefaultItems: true};
MoJack.menuModel =
{
visible: true,
items:
[
Mojo.Menu.editItem,
{label: 'About MoJack...', command: 'do-aboutMoJack'}
]
};
Code:
AppAssistant.prototype.handleCommand = function(event)
{
var cardStageController = this.controller.getStageController('stage');
if (cardStageController && event.type == Mojo.Event.command)
{
var currentScene = cardStageController.activeScene();
switch(event.command)
{
case 'do-aboutMoJack':
currentScene.showAlertDialog
({
onChoose: function(value) {},
title: 'MoJack - V1.0.0',
message: 'Copyright 2009, MoJack LLC',
choices: [{label: 'OK', value: ''}]
});
break;
}
}
}
__________________
MoBill - Use your Authorize.net account to bill your customers with your webOS device!! MoJack - Track your lost or stolen webOS device from anywhere! Time to get VIRAL Last edited by Laxidasical; 11/19/2009 at 04:51 PM. Reason: Typo/Correction |
11/18/2009, 07:51 PM
|
#3 (permalink) |
|
Member
![]() ![]() Join Date: Nov 2007
Location: Rhode Island, USA
Posts: 1,739
Likes Received: 15
Thanks: 381
Thanked 398 Times in 217 Posts
|
Why do you have you assistant and model instantiated as "MoJack.model" I didn't know you could do it that way. I assumed you always had to use "this.model". Maybe try it with the "this" prefix? Also, try making them globals? I don't personally know, tbh, but I usually just set them as "this.menuModel" unless I want to call the model to change it later, at which point i'll just set it to a global as "menuModel".
Maybe that'll help? |
11/18/2009, 08:08 PM
|
#4 (permalink) |
|
Member
![]() ![]() Join Date: Nov 2007
Location: Rhode Island, USA
Posts: 1,739
Likes Received: 15
Thanks: 381
Thanked 398 Times in 217 Posts
|
actually, on re-checking your post, you might want to double check your handleCommand function. I think you have a few extra things in there. Try looking up my original tutorial on here (for an example, you could technicially use any of the apps). But, in my example, on the second scene, I have a basic menu item and its handleCommand. I'm sorry I don't exactly remember what it is since my computer is down... For now. : /
|
11/19/2009, 12:52 AM
|
#5 (permalink) |
|
Member
![]() ![]() Join Date: Jul 2004
Location: Chicago
Posts: 574
Likes Received: 0
Thanks: 62
Thanked 60 Times in 42 Posts
|
I have a namespace called "MoJack" that is in my app-assistant.js setup function as well. This way I can declare MoJack.menuAttributes and MoJack.menuModel once and call them from any scene...makes changes to the menu easy since I don't have to do it in every scene. I had this same setup when this code with in stage-assistant.js and it worked great. Plus, I'm using several other variables & functions in the same namespace from different scenes with no problem. I did a quick test to make sure, I was able to grab data from both objects.
I agree, I believe the issue is somewhere in the handleCommand function since that was the only thing I changed since moving it from the stage assistant. The changes were required, because the app assistant needs to know which stage and scene to act on. I was following this example at Palm's Dev site. I've followed there example to the letter, then tried about a dozen other things. Nothing works!!! One other thing I should mention... The problem is that my menu doesn't display at all. I've tried removing any and every piece of code in my app that relates to menus (attributes, models, instantiations, handleCommand function)...nothing. Then I tried adding the Palm basic menu...nothing. It's almost like menus are completely disabled in my app! And yes, "visible" was set to "true" every time. At this point, ANY ideas are more than welcome!!!
__________________
MoBill - Use your Authorize.net account to bill your customers with your webOS device!! MoJack - Track your lost or stolen webOS device from anywhere! Time to get VIRAL Last edited by Laxidasical; 11/19/2009 at 01:24 PM. |
11/19/2009, 08:35 AM
|
#6 (permalink) |
|
Member
![]() ![]() Join Date: Nov 2007
Location: Rhode Island, USA
Posts: 1,739
Likes Received: 15
Thanks: 381
Thanked 398 Times in 217 Posts
|
Hmmm... In THAT case do you have other widgets that aren't working? The ONLY time I've seen even default Palm Menus not work is when a widget is improperly implemented. Try removing anything that has to do with menus and just run the scene with a button widget, or some really simple widget (if you don't have any others already). If no other widgets are coming up, you may have a problem elsewhere...
|
11/19/2009, 12:56 PM
|
#7 (permalink) |
|
Member
![]() ![]() Join Date: Jul 2004
Location: Chicago
Posts: 574
Likes Received: 0
Thanks: 62
Thanked 60 Times in 42 Posts
|
Some scenes have 1 widget while others have as many as 14. Everything in my app works except for the menus. I'm having a weird issue where the database gets deleted when I do updates via the SDK, but I don't think that's related to this problem.
Right now everything related to menus is gone. If I understand correctly, the basic Palm menu should display, correct?
__________________
MoBill - Use your Authorize.net account to bill your customers with your webOS device!! MoJack - Track your lost or stolen webOS device from anywhere! Time to get VIRAL Last edited by Laxidasical; 11/19/2009 at 01:17 PM. |
11/19/2009, 01:54 PM
|
#8 (permalink) |
|
Member
![]() ![]() Join Date: Nov 2007
Location: Rhode Island, USA
Posts: 1,739
Likes Received: 15
Thanks: 381
Thanked 398 Times in 217 Posts
|
wow, that's really odd. All the widgets work except for the menus?
Yeah, I would expect if you remove all customized menus from your scene, they should revert back to the defaults. Make sure you're not omitting the default menus somewhere higher up in your program. As in your stage assistant. Make sure that's COMPLETELY clear of all menu-related code. And then see if the basic default menus show up. Maybe? |
11/19/2009, 02:06 PM
|
#9 (permalink) |
|
Member
![]() ![]() Join Date: Jul 2004
Location: Chicago
Posts: 574
Likes Received: 0
Thanks: 62
Thanked 60 Times in 42 Posts
|
This is my COMPLETE stage-assistant.js file...
Code:
function StageAssistant() {}
This leads me to a question... In my app-assistant.js file, I'm using createStageWithCallback() to call the stage and push the main scene. For the attributes, I have... Code:
var stageArguments = {name: 'stage', lightweight: true};
|
11/19/2009, 02:17 PM
|
#10 (permalink) |
|
Member
![]() ![]() Join Date: Nov 2007
Location: Rhode Island, USA
Posts: 1,739
Likes Received: 15
Thanks: 381
Thanked 398 Times in 217 Posts
|
In all honesty, I've never worked with the stage assistant. I always just use it to pick the first scene that gets launched. Theoretically that makes sense, the stage assistant being called 'stage' but that may have deeper implications, I'm not exactly sure what though. : /
Sorry! A stage asistant can't have its own scene, could it? If it can, you could write something on it, make it NOT be lightweight and run it to see if this piece of code (calling it by the name "stage") actually works or not... : / |
11/19/2009, 02:27 PM
|
#11 (permalink) |
|
Member
![]() ![]() Join Date: Jul 2004
Location: Chicago
Posts: 574
Likes Received: 0
Thanks: 62
Thanked 60 Times in 42 Posts
|
From all my reading, the app assistant does have it's own stage/scene, but it's not accessible. This is why you have to use "noWindow: true" in appinfo.json when you have an app assistant. Also, "lightweight" is the only option supported right now. Supposedly that may change in the future.
I didn't know about the "noWindow: true" requirement when I first added the app assistant, and each time I launched my app, two cards would appear. One that had my app, and another (from the app assistant I guessing) that was completely blank. So now I'm moving all menu related stuff back to the stage assistant to see if I can get it working there. Wish me luck! By the way, you get your laptop back up and running? |
11/19/2009, 02:53 PM
|
#12 (permalink) |
|
Member
![]() ![]() Join Date: Nov 2007
Location: Rhode Island, USA
Posts: 1,739
Likes Received: 15
Thanks: 381
Thanked 398 Times in 217 Posts
|
Alright well, good luck! Hopefully you can revert back to your old style and may be find a way to work around it.
No. : /. I don't have my laptop up and running yet, still. I'm waiting on a CD, which for some stupid reason, I do not have with me. Hopefully in a day or two i'll get access to the CD and be back up on my programming feet. Idea: if it was working fine in the app assistant before, why did you move it to stage assistant? Was it just to have a custom/different menu in each stage? If you're going to need the same menu in most if not all of your scenes and just want to change a few, why don't you leave the universal one (in app assistant) and put up a custom one in the one scene you need to modify yet? |
11/19/2009, 02:57 PM
|
#13 (permalink) |
|
Member
![]() ![]() Join Date: Nov 2007
Location: Rhode Island, USA
Posts: 1,739
Likes Received: 15
Thanks: 381
Thanked 398 Times in 217 Posts
|
Bah! I don't have my reference codes with me, but when you instantiate the menu, did you try "this.sceneController..." I think MAYBE that sounds familiar... Either that, or I'm pulling random stuff out of the air now. >.<
|
11/19/2009, 03:05 PM
|
#14 (permalink) |
|
Member
![]() ![]() Join Date: Jul 2004
Location: Chicago
Posts: 574
Likes Received: 0
Thanks: 62
Thanked 60 Times in 42 Posts
|
It was the exact opposite. It was working fine in the stage assistant before. I had to add an app assistant because my app requires multiple stages. Then it broke. All of the examples I've come across have their menus setup (attributes, models, handleCommand) in the app assistant if they have one.
I REALLY miss having a well documented easy to search with great code examples website as a resource (like php.net). ;-/ Anyway, no luck moving it back to the stage assistant, and I think I understand why. The handleCommand function has to be in the appController since commands could be coming from multiple stages. Not sure it that is 100% correct, but it makes logical sense to me. I'm gonna work on something different for an hour or two and come back to this...any other suggestions would be great though! |
11/19/2009, 03:43 PM
|
#15 (permalink) |
|
Developer
![]() ![]() Join Date: Jul 2009
Posts: 1,400
Likes Received: 3
Thanks: 17
Thanked 1,540 Times in 376 Posts
|
unless you declared var menuModel, it looks like you want to be passing MoJack.menuModel and MoJack.menuAttributes to the setupWidget() call.
__________________
-Eric G WebOS Internals Developer. Follow me on Twitter for updates to my projects: | Virtual Keyboard | wIRC | SuperTux | AUPT | KeyBoss | freeTether | Donate |
11/19/2009, 04:18 PM
|
#16 (permalink) | |
|
Member
![]() ![]() Join Date: Jul 2004
Location: Chicago
Posts: 574
Likes Received: 0
Thanks: 62
Thanked 60 Times in 42 Posts
|
Quote:
In setup function... Code:
MoJack = {}; // CUSTOM NAMESPACE
// ... MORE CODE THAT SETS NAMESPACE VARIABLES ...
Code:
MoJack.menuAttributes = {omitDefaultItems: true};
MoJack.menuModel =
{
visible: true,
items:
[
Mojo.Menu.editItem,
{label: 'About MoJack...', command: 'do-aboutMoJack'}
]
};
|
|
11/19/2009, 04:27 PM
|
#17 (permalink) | |
|
Developer
![]() ![]() Join Date: Jul 2009
Posts: 1,400
Likes Received: 3
Thanks: 17
Thanked 1,540 Times in 376 Posts
|
Quote:
I was speaking about the this.controller.setupWidget(). In your first post you have this.controller.setupWidget(..., menuModel, ...) rather than (..., MoJack.menuModel, ...)
__________________
-Eric G WebOS Internals Developer. Follow me on Twitter for updates to my projects: | Virtual Keyboard | wIRC | SuperTux | AUPT | KeyBoss | freeTether | Donate |
|
11/19/2009, 04:29 PM
|
#18 (permalink) |
|
Developer
![]() ![]() Join Date: Jul 2009
Posts: 1,400
Likes Received: 3
Thanks: 17
Thanked 1,540 Times in 376 Posts
|
Also I believe you should be doing
var MoJack = {}
__________________
-Eric G WebOS Internals Developer. Follow me on Twitter for updates to my projects: | Virtual Keyboard | wIRC | SuperTux | AUPT | KeyBoss | freeTether | Donate |
11/19/2009, 04:59 PM
|
#19 (permalink) |
|
Member
![]() ![]() Join Date: Jul 2004
Location: Chicago
Posts: 574
Likes Received: 0
Thanks: 62
Thanked 60 Times in 42 Posts
|
I was using that as an example for a general instantiation question. I see how it can be confusing though, so I changed it!
![]() I don't believe using var would matter. As a matter of fact, on pages 46/47 of the O'Reilly book the author uses the following in his stage controller... Code:
// News namespace
News = {};
|
11/19/2009, 05:01 PM
|
#20 (permalink) |
|
Member
![]() ![]() Join Date: Jul 2004
Location: Chicago
Posts: 574
Likes Received: 0
Thanks: 62
Thanked 60 Times in 42 Posts
|
I forgot to mention...
Using var for the namespace actually locked my app up when I tried to launch it, so it's probably something that shouldn't be done at all (at least for global namespaces). |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|



