Warning Older Docs! - You are viewing documentation for a previous released version of RhoMobile Suite.

NativeMenubar

The NativeMenubar API lets you customize the Windows Mobile/CE native menu buttons.

Enabling the API

This API is part of the coreapi extension that is included automatically.

extensions: ["coreapi"]

JavaScript Usage

Be sure to review the JavaScript API Usage guide for important information about using this API in JavaScript.

Ruby Usage

Be sure to review the Ruby API Usage guide for important information about using this API in Ruby.

Properties

defaultMainMenu : ARRAY Read Only

This will return what the default right menu should be. This is a read-only property.

  • Object : HASH

  • Property Access:

    • Class: This property can only be accessed via the API class object.
      • Ruby: Rho::NativeMenubar.defaultMainMenu

    extraButton : HASH

    Defined behavior of the Left menu button for Windows Mobile applications. This takes the same HASH as a menu item {label: ‘Left Button’, action: ‘alert(“You pressed the left button”)’}. If your menu is using menu items via mainMenu, then be sure to not set an action for the extraButton. Setting an action for the extraButton will cause the mainMenu setting to be ignored.

    Property Access:

    • Class: This property can only be accessed via the API class object.
      • Javascript: Rho.NativeMenubar.extraButton
      • Ruby: Rho::NativeMenubar.extraButton

    extraMenu : ARRAY

    The Left menu items for Windows Mobile applications. This defines the list of menu choices when the extraButton is pressed.

  • Object : HASH

    Same values as for mainMenu.

  • Property Access:

    • Class: This property can only be accessed via the API class object.
      • Javascript: Rho.NativeMenubar.extraMenu
      • Ruby: Rho::NativeMenubar.extraMenu

    mainButton : HASH

    Defined behavior of the Right menu button for Windows Mobile applications. This takes the same HASH as a menu item {label: ‘Right Button’, action: ‘javascript: alert(“You pressed the right button”);’}. If your menu is using menu items via mainMenu, then be sure to not set an action for the mainButton. Setting an action for the mainButton will cause the mainMenu setting to be ignored.

    Property Access:

    • Class: This property can only be accessed via the API class object.
      • Javascript: Rho.NativeMenubar.mainButton
      • Ruby: Rho::NativeMenubar.mainButton

    mainMenu : ARRAY

    The Right menu items in Windows Mobile applications. This defines the list of menu choices when the mainButton is pressed.

  • Object : HASH

    • label : STRING

      Visible label.

    • action : STRING

      URL to page which will be loaded into tab. It may be path to Ruby controller action; i.e. ‘/app/Account’ would load the Account index action. For ruby callback use ‘callback:/app/Account’ Or JavaScript method to call: ‘javascript: methodOnTab();’. Or path to html page to load.

    • disabled : BOOLEAN Default: false

      Menu item will be displayed as disabled.

      Platforms:WM

    Property Access:

    • Class: This property can only be accessed via the API class object.
      • Javascript: Rho.NativeMenubar.mainMenu
      • Ruby: Rho::NativeMenubar.mainMenu

    Examples

    Customize the extra menu
    Rho.NativeMenubar.extraButton = {
        label: "Extra"
    };
    
    Rho.NativeMenubar.extraMenu = [
      {
          label: "Show alert 1",
          action: javascript:show_alert_1();,
      },
      {
          label: "Show alert 2",
          action: javascript:show_alert_2();,
      },
      {
          label: "Win the lottery",
          disabled: true
      }
    ];
                      
                     
    Rho::NativeMenubar.extraButton = {
      :label => "Extra"
    }
    
    Rho::NativeMenubar.extraMenu = [
      {
        :label => "Show alert 1",
        :action => url_for(:action => :show_alert_1)
      },
      {
        :label => "Show alert 2",
        :action => url_for(:action => :show_alert_2)
      },
      {
        :label => "Win the lottery",
        :disabled => true
      }
    ]
                      
                     
    Clear the main menu
    function remove_menuitems() {
        Rho.NativeMenubar.mainMenu = [];
    }
                      
                     
    def remove_menuitems
      Rho::NativeMenubar.mainMenu = []
    end