- Code: Select all
var menu = plugins.window.createPopupMenu();
menu.addMenuItem('Companies', scopes.nav.go_to_screen).methodArguments = [event, forms.companies_main];
menu.addMenuItem('Contacts', scopes.nav.go_to_screen).methodArguments = [event, forms.contacts_main];
menu.addSeparator();
...
and
- Code: Select all
/**
* @param {Number} arg1
* @param {Number} arg2
* @param {Number} arg3
* @param {Number} arg4
* @param {Number} arg5
* @param {JSEvent} event
* @param {RuntimeForm} a_form
*
* @properties={typeid:24,uuid:"E28E8FD9-261D-4905-B35D-1014111A0266"}
*/
function go_to_screen(arg1, arg2, arg3, arg4, arg5, event, a_form) {
a_form.controller.show();
scopes.globals.setupRecordStatus(a_form);
}
I am deliberately using the actual form in the code, this way Servoy will show an error if I try to reference a form which does not exist.
This works fine in Smart Client, the form object is passed to the go_to_screen function. In NG Client, it looks like the form_name is passed instead of the form object.
So the above code has to be rewritten as:
- Code: Select all
/**
* @param {Number} arg1
* @param {Number} arg2
* @param {Number} arg3
* @param {Number} arg4
* @param {Number} arg5
* @param {JSEvent} event
* @param {String|RuntimeForm} a_form
*
* @properties={typeid:24,uuid:"E28E8FD9-261D-4905-B35D-1014111A0266"}
*/
function go_to_screen(arg1, arg2, arg3, arg4, arg5, event, a_form) {
if(application.getApplicationType() == APPLICATION_TYPES.SMART_CLIENT) {
a_form.controller.show();
} else {
forms[a_form].controller.show();
}
scopes.globals.setupRecordStatus(a_form);
}
to work. Not a big issue as it is easy to rewrite the code to make it work by passing the form name, but it meant my main-menu did not work at first in NG-client.
Can the NG-client handle objects like forms in parameters?