Page 1 of 2 12 LastLast
Results 1 to 20 of 23
  1.    #1  
    When you setup an application menu widget in a scene and your handleCommand function is in your app-assistant.jsjsjs $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);
    ...rather than...

    Code:
    this.controller.setupWidget(Mojo.Menu.appMenu, MoJack.menuAttributes, MoJack.menuModel);
    I ask because I haven't been able to get my app menu working again since I added an app assistant. I'm instantiating using the second way listed above. Here is the code in my app controller...

    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'}
      ]
    };
    app assistant's handleCommend function...
    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;
        }
      }
    }
    Last edited by Laxidasical; 11/19/2009 at 04:51 PM. Reason: Typo/Correction
    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
  2.    #2  
    bump
    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
  3. #3  
    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?
  4. #4  
    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. : /
  5.    #5  
    I have a namespace called "MoJack" that is in my app-assistant.jsjsjs $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$ &$amp$; $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!!!
    Last edited by Laxidasical; 11/19/2009 at 01:24 PM.
    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
  6. #6  
    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...
  7.    #7  
    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?
    Last edited by Laxidasical; 11/19/2009 at 01:17 PM.
    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
  8. #8  
    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?
  9.    #9  
    This is my COMPLETE stage-assistant.jsjsjs $file$...

    Code:
    function StageAssistant() {}
    All of the code that was in there is now in my app-assistant.jsjsjs $file$, $as$ $done$ $in$ $the$ $example$ $in$ $the$ $Palm$ $webOS$ $O$'$Reilly$ $book$. $As$ $a$ $matter$ $of$ $fact$, $at$ $the$ $end$ $of$ $the$ $book$ $where$ $he$ $shows$ $all$ $of$ $the$ $code$ $from$ $every$ $file$, $he$ $doesn$'$t$ $include$ $the$ $stage$-$assistant$.$js$ $file$ $even$ $though$ $it$'$s$ $listed$ $as$ $being$ $in$ $the$ $directory$ $structure$ $and$ $in$ $his$ $sources$.$json$ $file$.

    This leads me to a question...
    In my app-assistant.jsjsjs $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};
    Since the name of the stage is 'stage', it defaults to stage-controller.jsjsjs, $right$???
    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
  10. #10  
    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.    #11  
    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?
    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
  12. #12  
    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?
  13. #13  
    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. >.<
  14.    #14  
    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!
    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
  15. #15  
    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
  16.    #16  
    Quote Originally Posted by emoney_33 View Post
    unless you declared var menuModel, it looks like you want to be passing MoJack.menuModel and MoJack.menuAttributes to the setupWidget() call.
    They are declared in app-assistant.jsjsjs:

    In setup function...
    Code:
    MoJack = {};  // CUSTOM NAMESPACE
    
    // ... MORE CODE THAT SETS NAMESPACE VARIABLES ...
    In handleLaunch function (under section that handles stage launch)...
    Code:
    MoJack.menuAttributes = {omitDefaultItems: true};
    
    MoJack.menuModel =
    {
    	visible: true,
    	items:
    	[
    		Mojo.Menu.editItem,
    		{label: 'About MoJack...', command: 'do-aboutMoJack'}
    	]
    };
    I've already checked to make sure that I can pull data from MoJack.menuAttributes and MoJack.menuModel in my scenes via a popup that displays their data. For good measure, I moved them from the app assistant to the scene directly before I instantiated the model as a test...still didn't work. :-(
    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
  17. #17  
    Quote Originally Posted by Laxidasical View Post
    They are declared in app-assistant.jsjsjs:

    In setup function...
    Code:
    MoJack = {};  // CUSTOM NAMESPACE
    
    // ... MORE CODE THAT SETS NAMESPACE VARIABLES ...
    In handleLaunch function (under section that handles stage launch)...
    Code:
    MoJack.menuAttributes = {omitDefaultItems: true};
    
    MoJack.menuModel =
    {
    	visible: true,
    	items:
    	[
    		Mojo.Menu.editItem,
    		{label: 'About MoJack...', command: 'do-aboutMoJack'}
    	]
    };
    I've already checked to make sure that I can pull data from MoJack.menuAttributes and MoJack.menuModel in my scenes via a popup that displays their data. For good measure, I moved them from the app assistant to the scene directly before I instantiated the model as a test...still didn't work. :-(

    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
  18. #18  
    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
  19.    #19  
    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 = {};
    He later did the same thing when he moved the stage controller code to the app controller. However, I tried your suggestion anyway! *grin* No such luck...
    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
  20.    #20  
    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).
    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
Page 1 of 2 12 LastLast

Posting Permissions