# JSMenuItem methodArguments

**URL:** <https://forum.servoy.com/t/jsmenuitem-methodarguments/11914>\
**Category:** Classic Servoy\
**Created:** [March 17, 2010, 10:58am UTC](https://forum.servoy.com/t/jsmenuitem-methodarguments/11914 "2010-03-17T10:58:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![victor.rojo](https://avatars.discourse-cdn.com/v4/letter/v/57b2e6/32.png) [@victor.rojo](https://forum.servoy.com/u/victor.rojo)\
**Post date:** [March 17, 2010, 10:58am UTC](https://forum.servoy.com/t/jsmenuitem-methodarguments/11914/1 "2010-03-17T10:58:04Z")

</div>

Hi!

Now the _methodArguments_ are passed as arguments 5 and so on to the callback method.  
I noticed that the argument 4 is the text of the menu item… but what are the previous arguments passed to the callback method?

Thanks!

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [March 17, 2010, 3:56pm UTC](https://forum.servoy.com/t/jsmenuitem-methodarguments/11914/2 "2010-03-17T15:56:26Z")

</div>

Victor,

About what plugin and what Servoy version is your question?  
Can you give a little sample code?

Does the sample code provided not help?

Rob

---

<div class="post-metadata">

**Author:** ![victor.rojo](https://avatars.discourse-cdn.com/v4/letter/v/57b2e6/32.png) [@victor.rojo](https://forum.servoy.com/u/victor.rojo)\
**Post date:** [March 18, 2010, 8:22am UTC](https://forum.servoy.com/t/jsmenuitem-methodarguments/11914/3 "2010-03-18T08:22:01Z")

</div>

Hi Rob.  
Sorry, I should be more specific…

Servoy version 5.1.0 - build 956

I’m talking about the popup menu plugin that now (from 5.0 I think) is inside the window plugin.  
Before this change to create a popup menu was:

```auto
var menu = new Array();

menu[1] = plugins.popupmenu.createMenuItem('Menu Item 1',<callback_method>);
menu[1].setMethodArguments(<array_arguments_for_callback_method>)

plugins.popupmenu.showPopupMenu(<triggered_element>, menu);

```

_\<array\_arguments\_for\_callback\_method\>_ was passed as arguments 0 and so on.

Now to create a popup menu:

```auto
var menu = plugins.window.createPopupMenu();
var menuItem1 = menu.addMenuItem('Menu Item 1',<callback_method>);

menuItem1.methodArguments = <array_arguments_for_callback_method>;

menu.show(<triggered_element>);

```

The sample code provided:

```auto
   var menu = plugins.window.getMenu(2).getItem(0);
// Set the text of the item.
menu.setText("Servoy");
// Set the method for the item.
menu.setMethod(callback);
// Set the arguments that can be read by the defined method. - array elements will be passed as arguments 5, 6 and so on to the callback method
menu.methodArguments = ["a","b"];
// Set the icon of the item.
menu.setIcon("media:///TipOfTheDay16.gif");
// Set the accelerator key of the item.
menu.setAccelerator("meta 4");
// Set the mnemonic key of the item.
menu.setMnemonic("e");
// Enable/disable the item.
menu.setEnabled(false);
// Set the item visible.
menu.setVisible(true);

```

I want to know what are the arguments 0 to 4 passed to the callback method.  
Maybe this info could be added to the wiki.

Thanks for the feedback!

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [March 19, 2010, 7:49am UTC](https://forum.servoy.com/t/jsmenuitem-methodarguments/11914/4 "2010-03-19T07:49:49Z")

</div>

Victor.

The window plugin in Servoy 5.1 contains a merge if the menubar plugin (originally from ITBE) and the popupmenu plugin.  
These arguments are a legacy from the menubar plugin and are kept for backward compatibility.

They are:  
[0] item index  
[1] parent item index  
[2] isSelected boolean  
[3] parent menu text  
[4] menu text

Rob

---

<div class="post-metadata">

**Author:** ![victor.rojo](https://avatars.discourse-cdn.com/v4/letter/v/57b2e6/32.png) [@victor.rojo](https://forum.servoy.com/u/victor.rojo)\
**Post date:** [March 22, 2010, 7:48am UTC](https://forum.servoy.com/t/jsmenuitem-methodarguments/11914/5 "2010-03-22T07:48:56Z")

</div>

Thank you very much Rob!
