// add a new menu to the menubarvar menubar =plugins.window.getMenuBar();var menu =menubar.addMenu();menu.text ="New Menu";// alternatively create a popup menu//var menu = plugins.window.createPopupMenu();// add a menu item at the first position in the menuvar entry =menu.addMenuItem(0);// alternatively add a checkbox at the first position//var entry = menu.addCheckBox(0);// or alternatively add a radiobutton at the first position//var entry = menu.addRadioButton(0);// disable the newly added entryentry.enabled =false;// give a name to the entry (the name is not visible anywhere)entry.name ="my_name";// make the entry selected (affects checkboxes and radiobuttons)entry.selected =true;// set the text of the entryentry.text ="menu entry";// set the callback methodentry.setMethod(feedback);// set the arguments to be sent to the callback method// (an array of elements which will be passed as arguments 5, 6 and so on to the callback method)// the first 5 arguments are fixed: // [0] item index// [1] parent item index// [2] isSelected boolean// [3] parent menu text// [4] menu textentry.methodArguments = [17,"data"];
methodArguments
Set arguments that are sent to the callback method.
// add a new menu to the menubarvar menubar =plugins.window.getMenuBar();var menu =menubar.addMenu();menu.text ="New Menu";// alternatively create a popup menu//var menu = plugins.window.createPopupMenu();// add a menu item at the first position in the menuvar entry =menu.addMenuItem(0);// alternatively add a checkbox at the first position//var entry = menu.addCheckBox(0);// or alternatively add a radiobutton at the first position//var entry = menu.addRadioButton(0);// disable the newly added entryentry.enabled =false;// give a name to the entry (the name is not visible anywhere)entry.name ="my_name";// make the entry selected (affects checkboxes and radiobuttons)entry.selected =true;// set the text of the entryentry.text ="menu entry";// set the callback methodentry.setMethod(feedback);// set the arguments to be sent to the callback method// (an array of elements which will be passed as arguments 5, 6 and so on to the callback method)// the first 5 arguments are fixed: // [0] item index// [1] parent item index// [2] isSelected boolean// [3] parent menu text// [4] menu textentry.methodArguments = [17,"data"];
name
The name of the menu item/checkbox/radiobutton. The name is used only internally, it is not visible in the user interface.
// add a new menu to the menubarvar menubar =plugins.window.getMenuBar();var menu =menubar.addMenu();menu.text ="New Menu";// alternatively create a popup menu//var menu = plugins.window.createPopupMenu();// add a menu item at the first position in the menuvar entry =menu.addMenuItem(0);// alternatively add a checkbox at the first position//var entry = menu.addCheckBox(0);// or alternatively add a radiobutton at the first position//var entry = menu.addRadioButton(0);// disable the newly added entryentry.enabled =false;// give a name to the entry (the name is not visible anywhere)entry.name ="my_name";// make the entry selected (affects checkboxes and radiobuttons)entry.selected =true;// set the text of the entryentry.text ="menu entry";// set the callback methodentry.setMethod(feedback);// set the arguments to be sent to the callback method// (an array of elements which will be passed as arguments 5, 6 and so on to the callback method)// the first 5 arguments are fixed: // [0] item index// [1] parent item index// [2] isSelected boolean// [3] parent menu text// [4] menu textentry.methodArguments = [17,"data"];
// add a new menu to the menubarvar menubar =plugins.window.getMenuBar();var menu =menubar.addMenu();menu.text ="New Menu";// alternatively create a popup menu//var menu = plugins.window.createPopupMenu();// add a menu item at the first position in the menuvar entry =menu.addMenuItem(0);// alternatively add a checkbox at the first position//var entry = menu.addCheckBox(0);// or alternatively add a radiobutton at the first position//var entry = menu.addRadioButton(0);// disable the newly added entryentry.enabled =false;// give a name to the entry (the name is not visible anywhere)entry.name ="my_name";// make the entry selected (affects checkboxes and radiobuttons)entry.selected =true;// set the text of the entryentry.text ="menu entry";// set the callback methodentry.setMethod(feedback);// set the arguments to be sent to the callback method// (an array of elements which will be passed as arguments 5, 6 and so on to the callback method)// the first 5 arguments are fixed: // [0] item index// [1] parent item index// [2] isSelected boolean// [3] parent menu text// [4] menu textentry.methodArguments = [17,"data"];
text
Get/set the text of the menu item/checkbox/radiobutton.; This can be also html if enclosed between html tags
// add a new menu to the menubarvar menubar =plugins.window.getMenuBar();var menu =menubar.addMenu();menu.text ="New Menu";// alternatively create a popup menu//var menu = plugins.window.createPopupMenu();// add a menu item at the first position in the menuvar entry =menu.addMenuItem(0);// alternatively add a checkbox at the first position//var entry = menu.addCheckBox(0);// or alternatively add a radiobutton at the first position//var entry = menu.addRadioButton(0);// disable the newly added entryentry.enabled =false;// give a name to the entry (the name is not visible anywhere)entry.name ="my_name";// make the entry selected (affects checkboxes and radiobuttons)entry.selected =true;// set the text of the entryentry.text ="menu entry";// set the callback methodentry.setMethod(feedback);// set the arguments to be sent to the callback method// (an array of elements which will be passed as arguments 5, 6 and so on to the callback method)// the first 5 arguments are fixed: // [0] item index// [1] parent item index// [2] isSelected boolean// [3] parent menu text// [4] menu textentry.methodArguments = [17,"data"];
Methods Detailed
doClick()
Script the selection (emulate a mouse click) of the item.
Returns: void
Sample
// add a new menu to the menubarvar menubar =plugins.window.getMenuBar();var menu =menubar.addMenu();menu.text ="New Menu";// alternatively create a popup menu//var menu = plugins.window.createPopupMenu();// add a menu itemvar entry =menu.addMenuItem("menu entry", feedback);// alternatively add a checkbox//var entry = menu.addCheckBox("menu entry", feedback);// or alternatively add a radiobutton//var entry = menu.addRadioButton("menu entry", feedback);// simulate a click on the entryentry.doClick();
getClientProperty(key)
Gets the specified client property for the menu item/checkbox/radiobutton based on a key.
// add a new menu to the menubarvar menubar =plugins.window.getMenuBar();var menu =menubar.addMenu();menu.text ="New Menu";// alternatively create a popup menu//var menu = plugins.window.createPopupMenu();// add a menu itemvar entry =menu.addMenuItem("menu entry", feedback);// alternatively add a checkbox//var entry = menu.addCheckBox("menu entry", feedback);// or alternatively add a radiobutton//var entry = menu.addRadioButton("menu entry", feedback);// NOTE: Depending on the operating system, a user interface property name may be available.// set the tooltip of the menu item/checkbox/radiobutton via client properties// keep the original tooltip in a form or global variableoriginalTooltip =entry.getClientProperty("ToolTipText");entry.putClientProperty("ToolTipText","changed tooltip");// later restore the original tooltip from the variable//var menubar = plugins.window.getMenuBar();//var menuIndex = menubar.getMenuIndexByText("New Menu");//var menu = menubar.getMenu(menuIndex);//var entry = menu.getItem(0);//entry.putClientProperty("ToolTipText", originalTooltip);
putClientProperty(key, value)
Sets the value for the specified client property key of the menu item/checkbox/radiobutton.
// add a new menu to the menubarvar menubar =plugins.window.getMenuBar();var menu =menubar.addMenu();menu.text ="New Menu";// alternatively create a popup menu//var menu = plugins.window.createPopupMenu();// add a menu itemvar entry =menu.addMenuItem("menu entry", feedback);// alternatively add a checkbox//var entry = menu.addCheckBox("menu entry", feedback);// or alternatively add a radiobutton//var entry = menu.addRadioButton("menu entry", feedback);// NOTE: Depending on the operating system, a user interface property name may be available.// set the tooltip of the menu item/checkbox/radiobutton via client properties// keep the original tooltip in a form or global variableoriginalTooltip =entry.getClientProperty("ToolTipText");entry.putClientProperty("ToolTipText","changed tooltip");// later restore the original tooltip from the variable//var menubar = plugins.window.getMenuBar();//var menuIndex = menubar.getMenuIndexByText("New Menu");//var menu = menubar.getMenu(menuIndex);//var entry = menu.getItem(0);//entry.putClientProperty("ToolTipText", originalTooltip);
setAccelerator(String)
Set the accelerator key of the menu item/checkbox/radiobutton.
// add a new menu to the menubarvar menubar =plugins.window.getMenuBar();var menu =menubar.addMenu();menu.text ="New Menu";// alternatively create a popup menu//var menu = plugins.window.createPopupMenu();// add a menu itemvar entry =menu.addMenuItem("menu entry", feedback);// alternatively add a checkbox//var entry = menu.addCheckBox("menu entry", feedback);// or alternatively add a radiobutton//var entry = menu.addRadioButton("menu entry", feedback);// define an accelerator for the menu entryentry.setAccelerator("ctrl alt Y");// also define a mnemonicentry.setMnemonic("y");// set a custom background color