Is it possible to pass arguments along with the functions in a popup menu?
If I just do
menu = plugins.popupmenu.createMenuItem(‘Description’,function(arg)) It will immediately go to function (but pas the argument) when trying to show the menu. Thanks.
Another fairly straight forward example. Popup trigger code:
var menu = new Array(
plugins.popupmenu.createMenuItem('New customer', LIST_action_control),
plugins.popupmenu.createMenuItem('Delete customer...', LIST_action_control)
)
//set method arguments to consecutive numbers
var x = 0
while (menu[x])
{
menu[x].setMethodArguments(x)
x ++
}
var elem = elements[application.getMethodTriggerElementName()]
if (elem != null)
{
plugins.popupmenu.showPopupMenu(elem, menu);
}
Method called (LIST_action_control)
//set label
switch (arguments[0]) {
case 0:
controller.newRecord(true)
controller.saveData();
FORM_on_show();
//get focus
forms.CUST_1_customer_form.elements.fld_name_first.requestFocus()
break
case 1:
var dialogInput = plugins.dialogs.showWarningDialog( 'Warning!', 'Are you sure you want to delete this record?',
'Yes', 'No')
if (dialogInput == 'Yes') {
//delete current record
controller.deleteRecord();
}
FORM_on_show();
break
}
I have changed the Popup trigger code so that it works with a separator “-”:
var menu = new Array(
plugins.popupmenu.createMenuItem(i18n.getI18NMessage('cbs.lb.facturados'), searchPopup),
plugins.popupmenu.createMenuItem(i18n.getI18NMessage('cbs.lb.no_facturados'),searchPopup),
plugins.popupmenu.createMenuItem( '-'),
plugins.popupmenu.createMenuItem(i18n.getI18NMessage('cbs.lb.mismo_cliente'),searchPopup)
)
//set method arguments to consecutive numbers
var x = 0
while (menu[x])
{
//if separator
if ( menu[x].text == undefined)
{
}
else
{
menu[x].setMethodArguments(x)
}
x ++
}
var elem = elements[application.getMethodTriggerElementName()]
if (elem != null)
{
plugins.popupmenu.showPopupMenu(elem, menu);
}