I have been playing around with the following sample genericMenu example. I want to call a genericForm when the select button is pressed. However nothing happens. The menu keep functioning in a never ending loop.
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 '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' : '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
'forceRedraw' : true
});
function selectCallback(selection) {
util.debug("Selected " + selection);
};
I have tried calling my function for the form within the callback function as follows.
function selectCallback(selection) {
util.debug("Selected " + selection);
myForm();
};
I have also tried adding a statement to stop observing the event as follows but all to no avail
function selectCallback(selection) {
util.debug("Selected " + selection);
digium.event.stopObserving({
'eventName' : 'digium.app.foreground'
});
myForm();
};
I have confirmed that the code within the form function is being executed. However teh menu remains on the screen and the keypress event keeps firing.