Results 1 to 13 of 13
  1.    #1  
    I can't seem to find a ton of documentation for the commandMenu but, I'm trying to make my application scalable. I'm very new at JavaScript and the code i have for it doesn't work:

    Code:
    this.cmdMenuModel = {
      visible: true,
      items: [
        {items:[{label: $L('Capture'), command:'capture'}]},
        {items:[{label: $L('My Photos'), command:'myphotos'}]}
      ]
    };
    
    this.controller.setupWidget(Mojo.Menu.commandMenu, undefined, this.cmdMenuModel);
    Any Ideas?
  2. #2  
    Do you just want to launch an app or write something and have the cmd place it in their before the app opens, so you don't have to wait.
    Because if you want to just type in part of an apps name and have it open, you can do that already without the cmd prompt. Like if you want to launch memos. Just type me and every app that starts with that will show up and just tap on it.
  3.    #3  
    both would work, just whatever is fastest and the most future proof.
  4. #4  
    I'd like to think I'm pretty decent about finding my way around the mojo framework, but I just can't figure out how to make this work.

    I want to have a menu button (or any widget, it doesn't really matter) launch the built-in calculator application. Is this possible? If so, how would I accomplish this?
  5. Tibfib's Avatar
    Posts
    345 Posts
    Global Posts
    347 Global Posts
    #5  
    See the API application included with the SDK. See the section Cross-Application Push.
  6.    #6  
    Quote Originally Posted by tjmarkham3 View Post
    I'd like to think I'm pretty decent about finding my way around the mojo framework, but I just can't figure out how to make this work.

    I want to have a menu button (or any widget, it doesn't really matter) launch the built-in calculator application. Is this possible? If so, how would I accomplish this?
    That's the same problem I'm having.
  7. #7  
    I'm sure your way works too, but when I create command menus, I do it like this:

    Code:
    this.controller.setupWidget(Mojo.Menu.commandMenu,
            this.attributes = {
               spacerHeight: 0,
               menuClass: 'no-fade'
            },
            this.model = {
              visible: true,
              items: [ 
                     {iconPath:"reload2.png", command: "SwitchCmd"},
                ]
        });
    Then I have a function (outside the main function, of course) that has a switch statement that looks something like this:
    Code:
    MainAssistant.prototype.handleCommand = function (event) {
    	
    	if (event.type === Mojo.Event.command) {
    		switch (event.command) {
    			case Mojo.Menu.helpCmd:
    				Mojo.Controller.stageController.pushScene('support');
    				break;
    			case Mojo.Menu.prefsCmd:
    				Mojo.Controller.stageController.pushScene('prefs');
    				break;
    			case "SwitchCmd":
    				//Code Goes Here
    				}
    				break;
    		}
    	}
    }
    That way, if you have an app-Menu you can use the same switch statement for your 'help' and 'preference' selections.

    Anyway, to launch another application, replace //Code Goes Here with:
    Code:
    this.controller.stageController.pushScene(
        { appId : 'com.palmdts.lightweightapplication', name: 'first' },
        { sublaunch : true}
    );
    This opens the new application in the same card as the old application. To go back to the old application, all you have to do is swipe back.

    That's just an example though. Clearly you would have to replace the appId with the appId of the application you're trying to launch.
  8.    #8  
    thanks! However, do what does this code do:

    Code:
    switch (event.command) {
    			case Mojo.Menu.helpCmd:
    				Mojo.Controller.stageController.pushScene('support');
    				break;
    			case Mojo.Menu.prefsCmd:
    				Mojo.Controller.stageController.pushScene('prefs');
    				break;
    could you help me create two simple commandMenu buttons one that opens the photo app and one that opens the camera app?
  9. #9  
    Oh that's just a switch statement in case you want to have an app-menu in your application. Basically, the code opens a 'preference' scene when you select 'Preferences' from the app-menu and a 'help' scene when you select 'Help' from the app-menu. I threw it in there just to illustrate the point that the switch statement can handle commands from command-menus as well as app-menus.

    To create the command-menu...
    Code:
    this.controller.setupWidget(Mojo.Menu.commandMenu,
            this.attributes = {
               spacerHeight: 0,
               menuClass: 'no-fade'
            },
            this.model = {
              visible: true,
              items: [ 
                     {iconPath:"reload2.png", command: "SwitchCmd"},
                     {iconPath:"reload2.png", command: "SwitchCmd2"},
                ]
        });
    Code:
    MainAssistant.prototype.handleCommand = function (event) {
    	
    	if (event.type === Mojo.Event.command) {
    		switch (event.command) {
    			case Mojo.Menu.helpCmd:
    				Mojo.Controller.stageController.pushScene('support');
    				break;
    			case Mojo.Menu.prefsCmd:
    				Mojo.Controller.stageController.pushScene('prefs');
    				break;
    			case "SwitchCmd":
    				this.controller.stageController.pushScene(
                                    { appId : 'com.palm.app.photos', name: 'first' },
                                    { sublaunch : true}
                                    );
    				break;
    			case "SwitchCmd2":
    				this.controller.stageController.pushScene(
                                    { appId : 'com.palm.app.camera', name: 'second' },
                                    { sublaunch : true}
                                    );
    				break;
    		}
    	}
    }
    You're going to have to change the blue code. They're the locations for the image files that will go on the buttons. Also, the red code might present some problems...I wouldn't know because I haven't tested it.
  10. #10  
    Sorry, the line that says:
    Code:
    { appId : 'com.palm.app.camera', name: 'second' },
    should actually be:
    Code:
    { appId : 'com.palm.app.camera', name:  'capture' },
  11.    #11  
    thanks! everything looks good!
  12.    #12  
    I'm new to JavaScript do you know a good book/guide or a good place to learn it?
  13. #13  
    No problem

    Personally, the first time I saw javascript was around two weeks ago. I know Java and C++ pretty throughly, and javascript really isn't all that different. Knowing other programing languages is definitely helpful. So I recommend that if you know any other programming languages, go look at some samples of javascript, and see what looks the same. That'll give you a good baseline. If you don't know any other programming languages, I'd recommend taking some programming classes (if you're still at school) even if they're not teaching Javascript. If you're out of school... well since I'm still at school I don't really have any advice...

    Also, just messing around with the sample code provided in the SDK proved to be extremely helpful.

    As far as websites/books go, this website seems to be useful: JavaScript Tutorials

    Personally I've never used their tutorials, but they have a large database of JSJSJS $methods$ $that$ $I$ $frequently$ $consult$ ($e$.$g$. JavaScript toExponential() Method).

Posting Permissions