Window Plugin

(part of package 'Servoy Default Services')

You can access it in code via: plugins.window

Properties

API

cancelFormPopup()

Close/cancels the current form popup panel without assigning a value to the configured data provider.

Example:

// Show a form as popup panel, where the closeFormPopup can pass return a value to a dataprovider in the specified scope.
plugins.window.showFormPopup(null,forms.orderPicker,foundset.getSelectedRecord(),"order_id");
// plugins.window.showFormPopup(null,forms.orderPicker,foundset.getSelectedRecord(),"order_id",-1,-1,100,100,true, false, onClose);
//
// function onClose(event) {application.output("Popup closed");}

closeFormPopup(retval)

Close the current form popup panel and assign the value to the configured data provider.

Example:

// Show a form as popup panel, where the closeFormPopup can pass return a value to a dataprovider in the specified scope.
plugins.window.showFormPopup(null,forms.orderPicker,foundset.getSelectedRecord(),"order_id");
// plugins.window.showFormPopup(null,forms.orderPicker,foundset.getSelectedRecord(),"order_id",-1,-1,100,100,true, false, onClose);
//
// function onClose(event) {application.output("Popup closed");}

Parameters:

  • {Object} retval Return value for data provider


createFormPopup(form)

Create a form popup that can be filled with data and shown.

Example:

plugins.window.createFormPopup(forms.orderPicker).show();

Parameters:

  • {Form} form The form to show

Returns: CustomType<window.FormPopup> A FormPopup instance that can be populated with data and displayed.


createPopupMenu(menu,callback)

Creates a new popup menu, either empty, or initialized from an existing JSMenu.

Example:

// create a popup menu
// var menu = plugins.window.createPopupMenu(menus.getMenu('contextMenu'), feedback);
var menu = plugins.window.createPopupMenu();

// add a menu item
menu.addMenuItem("an entry", callback);
  
if (event.getSource()) {
 // display the popup over the component which is the source of the event
 menu.show(event.getSource());
 // display the popup over the components, at specified coordinates relative to the component
 //menu.show(event.getSource(), 10, 10);
 // display the popup at specified coordinates relative to the main window
 //menu.show(100, 100);
}

Parameters:

  • {JSMenu} [menu] The JSMenu whose structure will be used to initialize the popup menu.

  • {Function} [callback] The menu item click handler that will be set on all popup menu items. The callback signature is: function(itemIndex:number, parentIndex: number, isSelected: boolean, parentMenu: String, menu: String)

Returns: CustomType<window.Popup> A new popup menu instance, optionally initialized with the provided JSMenu structure and callback function.


createShortcut(shortcut,callback,contextFilter,arguments,consumeEvent)

Create a shortcut.

Example:

// 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 handler
plugins.window.createShortcut('control shift I', scopes.globals.handleOrdersShortcut);
// global handler with a form context filter
plugins.window.createShortcut('control shift I', scopes.globals.handleOrdersShortcut, 'frm_contacts');
// form method called when shortcut is used
plugins.window.createShortcut('control RIGHT', forms.frm_contacts.handleMyShortcut);
// form method called when shortcut is used and arguments are passed to the method
plugins.window.createShortcut('control RIGHT', forms.frm_contacts.handleMyShortcut, new Array(argument1, argument2));
// Passing the method argument as a string prevents unnecessary form loading
//plugins.window.createShortcut('control RIGHT', 'frm_contacts.handleMyShortcut', new Array(argument1, argument2));
// Passing the method as a name and the contextFilter set so that this shortcut only trigger on the form 'frm_contacts'.
plugins.window.createShortcut('control RIGHT', 'frm_contacts.handleMyShortcut', 'frm_contacts', new Array(argument1, argument2));
// Num Lock and Substract shortcuts
plugins.window.createShortcut("NUMPAD8", handleMyShortcut);
plugins.window.createShortcut("SUBTRACT", handleMyShortcut);
// remove global shortcut and form-level shortcut
plugins.window.removeShortcut('menu 1');
plugins.window.removeShortcut('control RIGHT', 'frm_contacts');
// consuming they keystroke so that a default browser event will not happen
plugins.window.createShortcut('F4', scopes.globals.handleOrdersShortcut, 'frm_contacts', null, true);
// 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
//}
// NOTES:
// 1) shortcuts will not override existing operating system or browser shortcuts,
// choose your shortcuts carefully to make sure they work in all clients.
// 2) always use lower-case letters for modifiers (shift, control, etc.), otherwise createShortcut will fail.

Parameters:

  • {String} shortcut The keyboard shortcut combination (e.g., 'control shift I', 'F4', 'NUMPAD8') to trigger the action.

  • {Function} callback Scopes.scopename.methodname or formname.methodname String to target the method to execute

  • {String} [contextFilter] Form or element name ( ng only - specified by formName.elementName); only triggers the shortcut when on this form/element

  • {Array<object>} [arguments] An optional array of arguments to pass to the method when the shortcut is executed.

  • {Boolean} [consumeEvent] If true then the shotcut will consume the event and the default browser behavior will not be executed (default false)

Returns: Boolean True if the shortcut was successfully created; otherwise, false.


getFormPopup(form)

It will return a FormPopup with the form passed as an argument or null.

Example:

plugins.window.getFormPopup(forms.orderPicker)

Parameters:

  • {Form} form The form instance to be used in the popup.

Returns: CustomType<window.FormPopup> A FormPopup instance containing the specified form, or null if the popup could not be created.


removeShortcut(shortcut,contextFilter)

@clonedesc js_removeShortcut(String) Example:

as js_removeShortcut(String)

Parameters:

  • {String} shortcut The keyboard shortcut combination to be removed.

  • {String} [contextFilter] Form or element name ( ng only - specified by formName.elementName); only triggers the shortcut when on this form/element

Returns: Boolean True if the shortcut was successfully removed; otherwise, false.


showFormPopup(component,form,scope,dataProviderID,width,height,x,y,showBackdrop,doNotCloseOnClickOutside,onClose)

Show a form as popup panel, where the closeFormPopup can pass return a value to a dataprovider in the specified scope. Can show relative to a component or at specified coordinates. Show on specified location and backdrop is only supported in NGClient.

Example:

// Show a form as popup panel, where the closeFormPopup can pass return a value to a dataprovider in the specified scope.
plugins.window.showFormPopup(null,forms.orderPicker,foundset.getSelectedRecord(),"order_id");
// plugins.window.showFormPopup(null,forms.orderPicker,foundset.getSelectedRecord(),"order_id",-1,-1,100,100,true, false, onClose);
//
// function onClose(event) {application.output("Popup closed");}

Parameters:

  • {Runtimecomponent} component Element to show related to or null to center in screen

  • {Form} form The form to show

  • {Object} scope The scope to put retval into

  • {String} dataProviderID The dataprovider of scope to fill

  • {Number} [width] Popup width

  • {Number} [height] Popup height

  • {Number} [x] Popup x location

  • {Number} [y] Popup y location

  • {Boolean} [showBackdrop] Whatever to show a dimmed backdrop under the popup

  • {Boolean} [doNotCloseOnClickOutside] Whether to close on not close the popup on clicking outside

  • {Function} [onClose] A callback function that is being triggered once the formpopup window is being closed


Types

CheckBox

scripting type: CustomType<window.CheckBox> extends: MenuItem

FormPopup

scripting type: CustomType<window.FormPopup>

cancel()

Close/Cancel the current form and his children if applicable.

Example:

plugins.window.getFormPopup(forms.orderPicker).cancel();

component()

Returns the component.

Example:

plugins.window.createFormPopup(forms.orderPicker).component();

Returns: runtimecomponent The FormPopup itself if it's used as a setter or the component if no argument is given


component(component)

Set component form popup will be shown relative to. If null, will use coordinates or show at screen center.

Example:

plugins.window.createFormPopup(forms.orderPicker).component(elements.myelement).show();

Parameters:

Returns: FormPopup The FormPopup itself if it's used as a setter or the component if no argument is given


createFormPopup(form)

Create a form popup that can be filled with data and shown.

Example:

plugins.window.createFormPopup(forms.orderPicker).show();

Parameters:

  • form form The form to show

Returns: FormPopup ** FormPopup


dataprovider()

Returns the datprovider value

Example:

plugins.window.createFormPopup(forms.orderPicker).dataprovider('myid').scope(foundset.getSelectedRecord()).show();

Returns: string The FormPopup itself if it's used as a setter or the dataprovider value if no argument is given


dataprovider(dataprovider)

Set form popup dataprovider that will be set. If this is set, also scope needs to be specified.

Example:

plugins.window.createFormPopup(forms.orderPicker).dataprovider('myid').scope(foundset.getSelectedRecord()).show();

Parameters:

  • string dataprovider Form popup dataprovider

Returns: FormPopup The FormPopup itself if it's used as a setter or the dataprovider value if no argument is given


height()

Returns the height.

Example:

plugins.window.createFormPopup(forms.orderPicker).height(100).show();

Returns: int The FormPopu