# Questions about the popup menu plugin

**URL:** <https://forum.servoy.com/t/questions-about-the-popup-menu-plugin/5100>\
**Category:** Classic Servoy\
**Created:** [November 22, 2005, 5:09pm UTC](https://forum.servoy.com/t/questions-about-the-popup-menu-plugin/5100 "2005-11-22T17:09:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![SteveInLA](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@SteveInLA](https://forum.servoy.com/u/SteveInLA)\
**Post date:** [November 22, 2005, 5:09pm UTC](https://forum.servoy.com/t/questions-about-the-popup-menu-plugin/5100/1 "2005-11-22T17:09:19Z")

</div>

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:

```auto
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 :

```auto
track_units_hours_neither_both = 1;
controller.saveData();

```

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

```auto
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:

```auto
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

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [November 22, 2005, 5:52pm UTC](https://forum.servoy.com/t/questions-about-the-popup-menu-plugin/5100/2 "2005-11-22T17:52:11Z")

</div>

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:]( "Wink")

---

<div class="post-metadata">

**Author:** ![SteveInLA](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@SteveInLA](https://forum.servoy.com/u/SteveInLA)\
**Post date:** [November 22, 2005, 8:54pm UTC](https://forum.servoy.com/t/questions-about-the-popup-menu-plugin/5100/3 "2005-11-22T20:54:11Z")

</div>

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

```auto
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:

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

```

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

Steve in LA

---

<div class="post-metadata">

**Author:** ![patrick](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@patrick](https://forum.servoy.com/u/patrick)\
**Post date:** [November 22, 2005, 9:05pm UTC](https://forum.servoy.com/t/questions-about-the-popup-menu-plugin/5100/4 "2005-11-22T21:05:40Z")

</div>

I told Jan Blok that everybody would be requesting that, so I am glad that you did ![:lol:]( "Laughing")

---

<div class="post-metadata">

**Author:** ![Karel\_Broer](https://avatars.discourse-cdn.com/v4/letter/k/bcef8e/32.png) [@Karel\_Broer](https://forum.servoy.com/u/Karel_Broer)\
**Post date:** [March 9, 2007, 2:02pm UTC](https://forum.servoy.com/t/questions-about-the-popup-menu-plugin/5100/5 "2007-03-09T14:02:47Z")

</div>

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..

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [March 9, 2007, 2:34pm UTC](https://forum.servoy.com/t/questions-about-the-popup-menu-plugin/5100/6 "2007-03-09T14:34:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Karel\_Broer](https://avatars.discourse-cdn.com/v4/letter/k/bcef8e/32.png) [@Karel\_Broer](https://forum.servoy.com/u/Karel_Broer)\
**Post date:** [March 9, 2007, 3:36pm UTC](https://forum.servoy.com/t/questions-about-the-popup-menu-plugin/5100/7 "2007-03-09T15:36:06Z")

</div>

> 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:]( "Crying or Very sad")  
Could you tell me where the parent \> child \> child option is listed?

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [March 9, 2007, 4:08pm UTC](https://forum.servoy.com/t/questions-about-the-popup-menu-plugin/5100/8 "2007-03-09T16:08:57Z")

</div>

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.
