Questions about the popup menu plugin

I have started playing around with this plugin but I think I have hit a snag. There doesn’t seem to be any way to pass arguments to the method associated with a menu item. For instance, this works fine:

var elementName		= application.getMethodTriggerElementName();

var submenu = new Array(
	plugins.popupmenu.createMenuItem( "Units", set_trackUHBN_1 ),
	plugins.popupmenu.createMenuItem( "Hours", set_trackUHBN_2 ),
	plugins.popupmenu.createMenuItem( "Units And Hours", set_trackUHBN_3 ),
	plugins.popupmenu.createMenuItem( "Neither", set_trackUHBN_4 )
)

var menu = new Array(
	plugins.popupmenu.createMenuItem("<html><b>Track Service In...</b></html>",submenu)
)

elem	= elements[ elementName ];
plugins.popupmenu.showPopupMenu( elem, menu);

where the four separate methods such as set_trackUHBN_1 are :

track_units_hours_neither_both = 1;
controller.saveData();

However, it sure would be great if I could do this:

var elementName		= application.getMethodTriggerElementName();

var submenu = new Array(
	plugins.popupmenu.createMenuItem( "Units", set_trackUHBN(1) ),
	plugins.popupmenu.createMenuItem( "Hours", set_trackUHBN(2) ),
	plugins.popupmenu.createMenuItem( "Units And Hours", set_trackUHBN(3) ),
	plugins.popupmenu.createMenuItem( "Neither", set_trackUHBN(4) )
)

var menu = new Array(
	plugins.popupmenu.createMenuItem("<html><b>Track Service In...</b></html>",submenu)
)

elem	= elements[ elementName ];
plugins.popupmenu.showPopupMenu( elem, menu);

and the method set_trackUHBN could be:

track_units_hours_neither_both = arguments[ 0 ];
controller.saveData();

What happens now if I try this is that the method executes as the plugin creates the menu items. I know you are thinking, “Why not just use a value list?” Since the width of a value list is determined by the width of its associated field, I wouldn’t be able to do this:

Am I missing something or is the ablility to specify a method that inludes arguments not possible with this plugin?

Steve in LA

have a look at the setMethodArguments() (or the property methodArguments) function for the single menu item. I know it works, it was my request :wink:

Beautiful! I tried this and it seems to do the trick:

var elementName		= application.getMethodTriggerElementName();

var submenu = new Array(
	plugins.popupmenu.createMenuItem( "Units", set_trackUHBN ),
	plugins.popupmenu.createMenuItem( "Hours", set_trackUHBN ),
	plugins.popupmenu.createMenuItem( "Units And Hours", set_trackUHBN ),
	plugins.popupmenu.createMenuItem( "Neither", set_trackUHBN )
)

submenu[ 0 ].setMethodArguments(1);
submenu[ 1 ].setMethodArguments(2);
submenu[ 2 ].setMethodArguments(3);
submenu[ 3 ].setMethodArguments(4);

var menu = new Array(
	plugins.popupmenu.createMenuItem("<html><b>Track Service In...</b></html>",submenu)
)

elem	= elements[ elementName ];
plugins.popupmenu.showPopupMenu( elem, menu);

where set_trackUHBN is:

track_units_hours_neither_both = arguments[ 0 ];
controller.saveData();

Thank you Patrick for requesting that and hooray again for Servoy!

Steve in LA

I told Jan Blok that everybody would be requesting that, so I am glad that you did :lol:

I’dd like to show submenu items from related records in the popupmenu.

Is there a way to create sub items from items, like the treeBean can?
Like:
Main menu item > sub menu item > sub menu item, ect..

Hi Karel,

Yes you can.
Just right-click the createMenuItem function of the popupMenu plugin and select move Sample.
It shows an example how to do that.

Hope this helps.

ROCLASI:
Hi Karel,

Yes you can.
Just right-click the createMenuItem function of the popupMenu plugin and select move Sample.
It shows an example how to do that.

Hope this helps.

Hi Robert,

I only discover a parent > child option in the sample :cry:
Could you tell me where the parent > child > child option is listed?

Hi Karel,

The example shows indeed a submenu in the menu.
You can use the same principle to add a submenu to the submenu and so on.