Return Types
{column:width=80px}{column}{column}{column}
Method Summary
addToolBar(name, displayname, row)
Add a toolbar by name and optional displayname and row.
createShortcut(shortcut, method, form_name)
Create a shortcut.
getMenuCount()
Get the number of (top level) menu's.
getMenuIndexByText(menuName)
Retrieve the index of the item by text.
getToolBar(name)
Get the toolbar from the toolbar panel by name.
String[]
getToolbarNames()
Get all toolbar names from the toolbar panel.
removeAllMenus()
Remove all menus from the menubar.
void
removeMenu(index 1, index 2-n)
Remove the menu(s) at the selected index/indices.
removeShortcut(shortcut, form_name)
Remove a shortcut.
void
removeToolBar(name)
Remove the toolbar from the toolbar panel.
void
resetMenuBar()
Reset the menubar to the default.
void
validateMenuBar()
Use this when your add/remove/edit operation won't refresh.
{column:width=100%}{column}
Method Details
addMenu
(index)
Add the menu at the selected index (starting at 0) or add it at the end (empty).
Parameters
[index]
Also see
External links
Sample
// Note: method addMenu only works in the smart client. // Add the menu at the selected index (starting at 0) or add it at the end (empty). // add a menu at the given index // when you don't define an index the menu will be added at the last // positon of the menubar var menu = plugins.window.addMenu(); // set the text of the menu at the chose position menu.setText("add menu"); // set the mnemonic key menu.setMnemonic("a"); // enable the menu menu.setEnabled(true); // REMARK: normally you would add menu items, checkboxes etc in the same method // this example will show no menu items for now! // IMPORTANT: Working with menu's on developer and client can differ
addToolBar
(name, displayname, row)
Add a toolbar by name and optional displayname and row.
Parameters
name
[displayname]
[row]
Also see
External links
Sample
// Note: method addToolBar only works in the smart client. // Add a toolbar by name and optional displayname and row. // add a toolbar with only a name var toolbar = plugins.window.addToolBar("toolbar_0"); // add a toolbar with a name and internal name // var toolbar = plugins.window.addToolBar("toolbar_1", "toolbar_1"); // add a toolbar with a name, internal name and the row you want the // toolbar to show at. rownumber starts at 0 // var toolbar = plugins.window.addToolBar("toolbar_2", "toolbar_2", 3); // REMARK: normally you would add buttons, checkboxes etc in the same method // this example will show no buttons for now! // we will add them via the other methods on this form.
createPopupMenu
()
Replace with description
Parameters
Also see
External links
Sample
var popupmenu = plugins.window.createPopupMenu() var menuitem1 = popupmenu.addMenuItem('A',myMethod) var menuitem2 = popupmenu.addRadioButton('B',myMethod) var menuitem3 = popupmenu.addRadioButton('C',myMethod) var menuitem4 = popupmenu.addSeparator() var menuitem5 = popupmenu.addMenuItem('<html><b>Hello</b></html>',myMethod) var menuitem6 = popupmenu.addMenuItem('G', globals.myGlobalMethod) var submenu = popupmenu.addMenu('SubMenu') var subitem1 = submenu.addCheckBox('i18n:bla_bla',myMethod) var subitem2 = submenu.addCheckBox('he' , globals.myOtherGlobalMethod , 'media:///day_obj.gif') var subitem3 = submenu.addCheckBox('more' , globals.myOtherGlobalMethod ,null, 'm') //last parameter is mnemonic-key menuitem2.setSelected(true); menuitem6.setEnabled(false) subitem2.setSelected(true); var source = event.getSource() if (source != null) { popupmenu.show(source); //or you can set the coordinates popupmenu.show(10, 10); }
createShortcut
(shortcut, method, form_name)
Create a shortcut.
Parameters
shortcut
method
[form_name]
Also see
External links
Sample
// Create a shortcut. // this plugin uses the java keystroke parser // see http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/KeyStroke.html#getKeyStroke(java.lang.String) // global shortcut (on all forms) on 'apple 1' on a mac client and 'control 1' on other client platforms plugins.window.createShortcut('menu 1', 'globals.handleShortcut'); // global handler, only triggered when on form frm_orders plugins.window.createShortcut('control shift I', globals.handleOrdersShortcut, 'frm_orders'); // form method called when shortcut is used plugins.window.createShortcut('control LEFT', 'frm_products.handleShortcut', 'frm_products'); // same, but use method in stead of string plugins.window.createShortcut('control RIGHT', forms.frm_contacts.handleMyShortcut, 'frm_contacts'); // remove global shortcut and form-level shortcut plugins.window.createShortcut('menu 1'); plugins.window.removeShortcut('control RIGHT', 'frm_contacts'); // shortcut handlers are called with an jsevent argument ///** //* Handle keyboard shortcut. //* //* @param {JSEvent} event the event that triggered the action //*/ //function handleShortcut(event) //{ // application.output(event.getType()) // returns 'menu 1' // application.output(event.getFormName()) // returns 'frm_contacts' // application.output(event.getElementName()) // returns 'contact_name_field' or null when no element is selected //} // NOTE: shortcuts will not override existing operating system or browser shortcuts, // choose your shortcuts careful to make sure they work in all clients.
getMenu
(index)
Get the menu at the selected index (starting at 0).
Parameters
index
Also see
External links
Sample
// Note: method getMenu only works in the smart client. // Get the menu at the selected index (starting at 0). // get the menu from at index 2 // indexes start at 0 (zero) so index 2 is in fact position 3 var menu = plugins.window.getMenu(2); // set the text of the menu at the chose position menu.setText("get menu");$ // set the mnemonic key menu.setMnemonic("g"); // disable the menu menu.setEnabled(false); // REMARK: we actually changed an original menu! As a result resetting the // menubar will NOT reset the above changes. We need to reset the menu // manually the following way: // get the menu // var menu = plugins.window.getMenu(2); // reset the values to default // notice we use an i18n message here the same way you would use it with // standard Servoy methods and plugins // menu.setText("i18n:servoy.menuitem.showAll");// menu.setEnabled(true);
getMenuCount
()
Get the number of (top level) menu's.
Parameters
Also see
External links
Sample
// Note: method getMenuCount only works in the smart client. // Get the number of (top level) menu's. plugins.window.getMenuCount()
getMenuIndexByText
(menuName)
Retrieve the index of the item by text.
Parameters
menuName
Also see
External links
Sample
// Retrieve the index of the item by text. plugins.window.getMenuIndexByText()
getToolBar
(name)
Get the toolbar from the toolbar panel by name.
Parameters
name
Also see
External links
Sample
// Note: method getToolBar only works in the smart client. // Get the toolbar from the toolbar panel by name. // get the toolbar at the panel by name var toolbar = plugins.window.getToolBar("toolbar_0"); // add a button with a text and a method toolbar.addButton("button", feedback_button); // add an input array to the button for feedback in the selected method toolbar.addButton("button", feedback_button, [1, "2", "three"]); // add an icon to the button toolbar.addButton("button", feedback_button, [1, "2", "three"], "media:///yourimage.gif"); // add a tooltip to the button toolbar.addButton("button", feedback_button, [1, "2", "three"], "media:///yourimage.gif", "tooltip."); // show only an icon on the button and disable the button toolbar.addButton(null, feedback_button, [1, "2", "three"], "media:///yourimage.gif", "tooltip.", false); // add a separator toolbar.addSeparator(); // make the button non visible toolbar.addButton(null, feedback_button, [1, "2", "three"], "media:///yourimage.gif", "tooltip.",true, false); // and validate the changes // to make them know to the user interface) toolbar.validate();
String[]
getToolbarNames
()
Get all toolbar names from the toolbar panel.
Parameters
Also see
External links
Sample
// Note: method getToolbarNames only works in the smart client. // Get all toolbar names from the toolbar panel. // create an array of toolbar names var names = plugins.window.getToolbarNames(); // create an empty message variable var message = ""; // loop through the array for (var i = 0 ; i < names.length ; i++) { //add the name(s) to the message message += names[i] + "\n"; } // show the message plugins.dialogs.showInfoDialog("toolbar names", message);
removeAllMenus
()
Remove all menus from the menubar.
Parameters
Also see
External links
Sample
// Note: method removeAllMenus only works in the smart client. // Remove all menus from the menubar. // Remove all menus from the menubar. // Potentially dangerous because all accelerator (short) keys // will be deleted also (including the quit item) plugins.window.removeAllMenus();
void
removeMenu
(index 1, index 2-n)
Remove the menu(s) at the selected index/indices.
Parameters
index 1
[index 2-n]
Returns
void
Also see
External links
Sample
// Note: method removeMenu only works in the smart client. // Remove the menu(s) at the selected index/indices. // To remove the last menu in the menubar we count the number of menu's in the menubar // because the index starts at 0 we have to substract 1 from the counted menu's // to actually remove the last menu from the menubar plugins.window.removeMenu(plugins.window.getMenuCount() - 1); // To remove the last 3 (three) menu's from the menubar we // can do that by adding additional indexes to the method // and delimit them with a comma. var index = plugins.window.getMenuCount() - 1; // remove the last item plugins.window.removeMenu(index); // remove 3 (three) items // plugins.window.removeMenu(this.index, index-1, 2); // For 'security' reasons it is best to ALWAYS remove the menu with the last index // first to avoid index out of range issues and other issues // EXAMPLE: when you first remove the menu at index 2 and then the menu at index 4 // you actually remove the menu at index 2 and index 5 // after removing the menu at index 2 all other menu's moved one index to the left // so the menu at index 4 moved to index 3 and the menu at index 5 moved to index 4 etc.
removeShortcut
(shortcut, form_name)
Remove a shortcut.
Parameters
shortcut
[form_name]
Also see
External links
Sample
// Remove a shortcut. // this plugin uses the java keystroke parser // see http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/KeyStroke.html#getKeyStroke(java.lang.String) // global shortcut (on all forms) on 'apple 1' on a mac client and 'control 1' on other client platforms plugins.window.createShortcut('menu 1', 'globals.handleShortcut'); // global handler, only triggered when on form frm_orders plugins.window.createShortcut('control shift I', globals.handleOrdersShortcut, 'frm_orders'); // form method called when shortcut is used plugins.window.createShortcut('control LEFT', 'frm_products.handleShortcut', 'frm_products'); // same, but use method in stead of string plugins.window.createShortcut('control RIGHT', forms.frm_contacts.handleMyShortcut, 'frm_contacts'); // remove global shortcut and form-level shortcut plugins.window.createShortcut('menu 1'); plugins.window.removeShortcut('control RIGHT', 'frm_contacts'); // shortcut handlers are called with an jsevent argument ///** //* Handle keyboard shortcut. //* //* @param {JSEvent} event the event that triggered the action //*/ //function handleShortcut(event) //{ // application.output(event.getType()) // returns 'menu 1' // application.output(event.getFormName()) // returns 'frm_contacts' // application.output(event.getElementName()) // returns 'contact_name_field' or null when no element is selected //} // NOTE: shortcuts will not override existing operating system or browser shortcuts, // choose your shortcuts careful to make sure they work in all clients.
void
removeToolBar
(name)
Remove the toolbar from the toolbar panel.
Parameters
name
Returns
void
Also see
External links
Sample
// Note: method removeToolBar only works in the smart client. // Remove the toolbar from the toolbar panel. // removing a toolbar from the toolbar panel is done by name // the plugin checks the existence of the toolbar // when the toolbar does not exist it will not throw an error though. plugins.window.removeToolBar("toolbar_0"); plugins.window.removeToolBar("toolbar_1"); plugins.window.removeToolBar("toolbar_2");
void
resetMenuBar
()
Reset the menubar to the default.
Parameters
Returns
void
Also see
External links
Sample
// Note: method resetMenuBar only works in the smart client. // Reset the menubar to the default. // When the menubar settings are solution specific it is advised to reset // the bar to its default settings when closing the solution. // Another reason is that when a client/developer is started first the // plugin will save the current settings in memory // REMARK: Don't manipulate standard Servoy menuitems but remove // them and create new ones! Due to the way menuitems are managed by java it is not // possible to reset a menuitem anymore. plugins.window.resetMenuBar();
void
setFullScreen
()
Replace with description
Parameters
Returns
void
Also see
External links
Sample
plugins.window.setFullScreen(true)
void
setMenuVisible
()
Replace with description
Parameters
Returns
void
Also see
External links
Sample
plugins.window.setMenuVisible(false)
void
setStatusBarVisible
()
Replace with description
Parameters
Returns
void
Also see
External links
Sample
plugins.window.setStatusBarVisible()
void
setToolBarVisible
()
Replace with description
Parameters
Returns
void
Also see
External links
Sample
plugins.window.setToolBarVisible(false)
void
validateMenuBar
()
Use this when your add/remove/edit operation won't refresh.
Parameters
Returns
void
Also see
External links
Sample
// Note: method validateMenuBar only works in the smart client. // Use this when your add/remove/edit operation won't refresh. plugins.window.validateMenuBar();