Phone API Reference - UI Extended - genericMenu.show
genericMenu.show
Description
Shows a standard menu as used in Digium Apps. Adds the functionality such as pressing a number pad key to jump to that menu item.
Basic Example:
genericMenu.show(parameters); |
Parameters
Name | Required | Type | Default | Description |
---|---|---|---|---|
id | Yes | string |
| Unique identifier for the menu. |
menu | Yes | array |
| Array of objects representing the the items in the menu. Array of objects in the form {'text' : 'Menu item text', 'id' : 'id for the selection'}. |
object | Yes | object |
| Object containing the processMenuAction() method, which is called when the user makes any selection from the menu. |
title | Yes | string |
| String to display in the title bar. |
softkeys | No | array |
| Array of softkeys for each menu item. Array members should be objects like: {'label' : 'softkey Label', 'actionId' : 'id of the action when a softkey is pressed'} |
onkeyselect | No | widget |
| Widget |
onkeycancel | No | function |
| Callback function for when the user presses the cancel hard button. |
Examples
genericMenu.show creates a menu
var genericMenu = require('genericMenu');
var handler = {};
//This handler is called when any assigned softkeys/hardkeys are pressed
//It receives the id of the selected item and the action as parameters
handler.processMenuAction = function (params) {
switch (params.actionId) {
case 'select':
selectCallback(params.selectionId);
break;
case 'help':
helpCallback(params.selectionId);
break;
case 'getInfo':
getInfo(params.selectionId);
break;
case 'exit':
digium.background();
break;
}
};
//the menu items are defined in an array
var items = [
{
'text' : 'Menu Entry 1',
'id' : 'item_1'
},
{
'text' : 'Menu Entry 2',
'id' : 'item_2'
},
{
'text' : 'Menu Entry 3',
'id' : 'item_3'
},
{
'text' : 'Menu Entry 4',
'id' : 'item_4'
}
];
//the softkeys are defined in an array
var softkeys = [
{
'label' : 'Select',
'actionId' : 'select',
'icon' : app.images.softKeys.select
},
{
'label' : 'Help',
'actionId' : 'help'
},
{
'label' : 'Info',
'actionId' : 'getInfo'
},
{
'label' : 'Cancel',
'actionId' : 'exit'
}
];
//show the menu
genericMenu.show({
'id' : 'menu_1',
'menu' : items,
'object' : handler,
'title' : 'Menu Title',
'softkeys' : softkeys,
'onkeyselect' : selectCallback,
'onkeycancel' : digium.background
}); |