Using JavaScript to customize menus

From JavaScript, menu is the name of the JavaScript object. You do not need to instantiate the menu object before accessing it from JavaScript.

Customizing the main menu

At the level of the M-Business Client main menu, you can control remove a menu so that it does not even appear. On platforms where a user action is required to display the M-Business Client main menu, you can customize the menu softkey label.

JavaScript commands that access the menu object to customize the main menu take the following form:

menu.menu_function

Valid values for menu_function are given in the following table.

Values for menu_function to use with the M-Business Client main menu

menu_function

Data type

Description

label

string

The menu softkey label displayed on platforms where a user action is required to display the M-Business Client main menu.

isAvail()

boolean

False for a menu that has been removed; true otherwise.

remove()

void

Removes the specified menu from the M-Business Client main menu. The menu is automatically restored in the user's next M-Business Client session, but cannot be restored in the current session.

Customizing individual menu items

JavaScript commands that access the menu object to customize individual menu items take the following form:

menu.menu_item.menu_item_function

Valid values for menu_item and menu_item_function are given in the following two tables.

Values for menu_item_function to use with individual menu items

menu_function

Data type

Description

enabled

boolean

Returns true if menu_item is enabled; false otherwise. Setting to true enables menu_item; setting to false disables it.

On the menu items listed below, M-Business Client will override any changes in the menu item's enabled status that conflict with the device state. This will happen the first time that the user displays the menu containing that menu item, so the user will never see the conflicting setting.

  • Back

  • Copy

  • Cut

  • Forward

  • Full screen

  • Paste

  • Select all

  • Sync

  • Work Offline

  • Work Online

label

string

The label displayed for menu_item.

isAvail()

boolean

False if menu_item is unavailable on the current M-Business Client platform, or has been removed; true otherwise.

remove()

void

Removes menu_item from display in its M-Business Client menu. Removed menu items are automatically restored in the user's next M-Business Client session, but cannot be restored in the current session.

Values for menu_item

menu_item

Default menu label

about

About

addBookmark

Add Bookmark

back

Back

bookmarkManager

Bookmark Manager

cacheManager

Cache Manager

channelManager

Channel Manager

copy

Copy

cut

Cut

exit

Exit

find

Find

findNext

Find Next

findPrevious

Find Previous

formManager

Forms Manager

forward

Forward

fullScreen

Full Screen

goHome

Home

help

Help

openPage

Open Page

pageOption

Page Options

paste

Paste

reloadPage

Reload Page

selectAll

Select All

serverOption

Server Options

syncAll

Sync All

workOffline

Work Offline

workOnline

Work Online

Note

Some menu items are not available across all M-Business Client platforms. For example, the Home menu item is not available on Win32 devices. An attempt to access a missing menu item simply results in a no-op and does not cause any exceptions. Use the isAvail() method can use to test for the availability of a given menu item.

Note

The valid labels for menu_item in the table above are based on their respective labels on the in M-Business Client on the Windows Mobile 5 and later platform family. Some menu items have different labels on other M-Business Client platforms. For example, the Page Options menu item is called Preferences, or just Options, on some platforms.

If you attempt to access a menu item that is not available, it results in a no-op that does not cause any exceptions. You can use isAvail() to determine the availability of a menu item.

Examples

Disable the Forms Manager menu item if it is enabled:

if(menu.formManager.enabled)
    menu.formManager.enabled = false;

Remove the Forms Manager menu item completely:

menu.formManager.remove();

Change the label of the Sync All menu item:

menu.syncAll.label = "Update all channels";