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

NativeToolbar

The NativeToolbar method let you create and remove a toolbar at runtime.

Only a Toolbar or a Tabbar can present in application – both can not be used at the same time.

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

Methods

create(ARRAY toolbarElements, HASH toolBarProperties)

Removes the current toolbar/tabbar and replaces it with this one.

Parameters

  • toolbarElements : ARRAY

    Array of Toolbar elements. Do not create more than five elements for maximum portability.Toolbar elements are not scrollable, so if some buttons will not fit into the screen dimensions, they will be invisible.

    • toolbarElement : HASH

      Properties of Toolbar elements. Either :icon or :label must be specified. If both are specified, :icon is drawn and :label is discarded.

      • label : STRING

        Visible label to display instead of an icon.For predefined actions, icon will be displayed.Android,iOS note: for predefined actions no label will be displayed.

      • action : STRING

        URL to call when button is pressed or special value.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: methodOnButton();'.

        Possible Values :

        separator
        Add a separator to the toolbar. If only one separator is specified, then elements after separator will be right-aligned. If more then one separator is added: on WM/CE, platform dependent separator will be displayed, on Android/iOS center-aligned groups will be created. Platforms: WM, Win32, iOS, Android
        exit
        Exit the application.
        close
        Exit the application.
        options
        Navigate to Settings page, defined in configuration file.
        home
        Navigate to Home page, defined in configuration file.
        refresh
        Refresh current page.
        back
        Perform back action or execute browser back.
        log
        Display Log View window. Platforms: WM, Win32, iOS, Android
        fullscreen
        Expand application window to full screen. Platforms: WM, Win32, Android, WP8
        sync
        Run full sync command.
        minimize
        Minimize application window. Platforms: WM, Win32
        SIP
        Display software keyboard window.Set Rho.System.keyboardState to Rho.System.KEYBOARD_AUTOMATIC to use this element. Platforms: WM
      • icon : STRING

        Relative path to toolbar item icon in your rhodes app (typically located in '/public/images/'). Icon is ignored for predefined actions, icon will be displayed even if no icon specified. iPhone and Android: Icons must be no more than 30x30 pixels and must be in .png format. Windows Mobile: Icons can be any size, but all icons should have same size (default - 48x48). .png and .bmp formats are supported.

      • coloredIcon : BOOLEAN Default: false

        Use colored icon in toolbar on iPhone instead of standard monochrome white icon (prepared from image alpha). Platforms:iOS

      • width : INTEGER

        Button width in pixel. Used to define separator width when more than one separator specified. Platforms:WM

  • toolBarProperties : HASH

    Properties of TabBar.

    • backgroundColor : INTEGER

      Background color of the toolbar.

    • maskColor : INTEGER Default: 0xFFFFFF

      Image mask color(transparent color). Platforms:WM, Win32

    • viewHeight : INTEGER

      Toolbar height in pixels. Platforms:WM, Win32

Synchronous Return:

  • Void

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • JavaScript: Rho.NativeToolbar.create(ARRAY toolbarElements, HASH toolBarProperties)
    • Ruby: Rho::NativeToolbar.create(ARRAY toolbarElements, HASH toolBarProperties)

remove()

Removes the current toolbar. Does nothing if there is no active toolbar.

Synchronous Return:

  • Void

Method Access:

  • Class Method: This method can only be accessed via the API class object.
    • JavaScript: Rho.NativeToolbar.remove()
    • Ruby: Rho::NativeToolbar.remove()

Examples

Create native toolbar
Create a native Toolbar
Rho.NativeToolbar.create([{
        label: "Home",
        action: Rho.Application.startURI
    }, {
        label: "example.com",
        action: "http://www.example.org"
    }], {})
                   
                 
Rho::NativeToolbar.create([{
  :label => "Home",
  :action => url_for(Rho::Application.startURI)
  },
  {
  :label => "example.com",
  :action => "http://www.example.com",
  }
], {})
                   
                 
Remove the toolbar
Remove the toolbar
Rho.NativeToolbar.remove();
                   
                 
Rho::NativeToolbar.remove