I’m trying create a method that shows a valuelist with checkboxes next to each value when button is clicked.
So far this is what I have
var engDataSet = application.getValueListItems(‘engineerlist’)
var engNames = engDataSet.getColumnAsArray(1) //get the name of all the engineers
var submenu = new Array()
for(var i = 1; i < engDataSet.getMaxRowIndex(); i ++)
{
submenu[i-1] = plugins.popupmenu.createCheckboxMenuItem(engNames*, myMethod())*
submenu[i-1].setMethodArguments(new Array(application.getMethodTriggerElementName(),application.getMethodTriggerFormName()))* } var menu = new Array (plugins.popupmenu.createMenuItem(‘Engineers’, submenu)) menu[0].setSelected(true); var elem = elements[application.getMethodTriggerElementName()]; if (elem != null) {
plugins.popupmenu.showPopupMenu(elem, menu);* } [/quote] I’m very unsure what should be in myMethod().
myMethod is the method that will be fired if the user selects a menu item. But you pass that in the wrong way, an error that many people seem to make.
If you want to pass a method to a plugin, you have to pass it as
myMethod
simply that. A typical error is
myMethod()
which will execute that method right where you have put that and pass a possible result of myMethod to the plugin instead of a reference to that method. Also wrong is
it’s working now. but now I have 2 more questions.
is it possible for the users to check/select a few values on the checkbox popup menu before the menu closes. So far, the menu closes after a value is selected.
I want “myMethod” to get the text of the value that has been selected. How does “myMethod” know which value is selected???