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:

Parameters:

  • {Object} retval Return value for data provider


createFormPopup(form)

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

Example:

Parameters:

  • {Form} form The form to show

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


createPopupMenu()

Creates a new empty popup menu

Example:

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


createPopupMenu(menu,callback)

Creates a new popup menu initialized from an existing JSMenu.

Example:

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:

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:

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:

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:

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:


component()

Returns the component.

Example:

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:

Parameters:

  • runtimecomponent component The form to show 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:

Parameters:


dataprovider()

Returns the datprovider value

Example:

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:

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:

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


height(height)

Set form popup height. If not set, form design height will be used.

Example:

Parameters:

  • int height Form popup height Returns: FormPopup The FormPopup itself if it's used as a setter or the height if no argument is given


onClose()

Returns the onClose function value

Example:

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


onClose(onClose)

Set the onclose function that is called when the closeFormPopup is called. This onClose will get a JSEvent as the first argument, and the return value that is given to the closeFormPopup(retvalue) call.

Example:

Parameters:

  • function onClose Function that needs to be called when closed Returns: FormPopup The FormPopup itself if it's used as a setter or the function value if no argument is given


scope()

Returns the scope object

Example:

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


scope(scope)

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

Example:

Parameters:

  • object scope Form popup scope to modify Returns: FormPopup The FormPopup itself if it's used as a setter or the scope object if no argument is given


show()

Show form popup using parameters that were set

Example:


showBackdrop()

Returns the backdrop value

Example:

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


showBackdrop(showBackdrop)

Set whether backdrop will be shown. Default value is false.

Example:

Parameters:

  • boolean showBackdrop Form popup showBackdrop Returns: FormPopup The FormPopup itself if it's used as a setter or the showBackdrop value if no argument is given


width()

Returns the width.

Example:

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


width(width)

Set form popup width. If not set, form design width will be used.

Example:

Parameters:

  • int width Form popup width Returns: FormPopup The FormPopup itself if it's used as a setter or the width if no argument is given


x()

Returns the x.

Example:

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


x(x)

Set form popup x location. The priority sequence for location is: related element, set location, center of screen.

Example:

Parameters:

  • int x Form popup x location Returns: FormPopup The FormPopup itself if it's used as a setter or the x if no argument is given


y()

Returns the y value

Example:

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


y(y)

Set form popup y location. The priority sequence for location is: related element, set location, center of screen.

Example:

Parameters:

  • int y Form popup y location Returns: FormPopup The FormPopup itself if it's used as a setter or the y value if no argument is given


Represents a Menu component. Extends BaseMenu to provide a popup menu with display text and basic actions. scripting type: CustomType<window.Menu>

extends: BaseMenu

  • text

    • The text label displayed for the menu.

    • Type: string

doClick()

Script the selection (emulate a mouse click) of the menu.

Example:


setEnabled(enabled)

Set the the selected menu enabled or disabled.

Example:

Parameters:

  • boolean enabled The enabled state; true to enable the menu, false to disable.


setIcon(icon)

Set the icon of the menu.

Example:

Parameters:

  • object icon The icon to be used, which can be a media URL or an object representing the icon.


setMnemonic(mnemonic)

Set the mnemonic of the selected menu.

Example:

Parameters:

  • string mnemonic The mnemonic key used for keyboard shortcuts.


MenuItem type defines public properties and server-side API for menu items. scripting type: CustomType<window.MenuItem>

  • enabled

    • Indicates whether the menu item is enabled.

    • Type: protected

    • Default Value: true

  • methodArguments

    • An array of arguments to pass to the callback when the menu item is activated.

    • Type: object[]

  • name

    • The unique name for the menu item.

    • Type: string

  • selected

    • Indicates whether the menu item is selected.

    • Type: boolean

  • text

    • The display text shown for the menu item.

    • Type: string

  • tooltipText

    • The tooltip text to be shown for this menu

    • Type: string

doClick()

Script the selection (emulate a mouse click) of the item.

Example:


getClientProperty(key)

Gets the specified client property for the menu item/checkbox/radiobutton based on a key.

Example:

Parameters:

  • object key The key for the client property.


putClientProperty(key,value)

Sets the value for the specified client property key of the menu item/checkbox/radiobutton.

Example:

Parameters:

  • object key The key for the client property.

  • object value The value to set for the client property.


setAccelerator(accelerator)

Set the accelerator key of the menu item/checkbox/radiobutton.

Example:

Parameters:

  • string accelerator The accelerator key string, e.g. "ctrl alt Y".


setBackgroundColor(bgColor)

Set the background color of the menu item/checkbox/radiobutton. Parameters:

  • string bgColor The background color as a string (e.g., "#111111").


setForegroundColor(fgColor)

Set the foreground color of the menu item/checkbox/radiobutton. Parameters:

  • string fgColor The foreground color as a string (e.g., "#EE5555").


setIcon(icon)

Set the icon of the menu item/checkbox/radiobutton.

Example:

Parameters:


setMethod(method,arguments)

Set the method for the menu item/checkbox/radiobutton.

Example:

Parameters:

  • function method The callback function to be executed when the menu item is activated.

  • object[] [arguments] An array of additional arguments to be passed to the callback function. The first five arguments are fixed: [0] item index, [1] parent item index, [2] isSelected boolean, [3] parent menu text, [4] menu text.


setMnemonic(mnemonic)

Set the icon of the menu item/checkbox/radiobutton.

Example:

Parameters:

  • string mnemonic The mnemonic key to be used as a shortcut indicator for the menu item.


setVisible(visible)

Set the item visible.

Example:

Parameters:

  • boolean visible The visibility state of the menu item.


Popup type defines public properties and server-side API for popup menus. scripting type: CustomType<window.Popup>

extends: BaseMenu

  • cssClass

    • CSS class for custom styling of the popup.

    • Type: string

show(component,positionTop)

Show the popup menu relative to the specified component. If there is not enough space above or under the component, the behavior is undefined (the browser will decide how menu is displayed)

Example:

Parameters:

  • runtimecomponent component The component where this popup is linked in

  • boolean [positionTop] The positionTop where to show the popup (default false)


show(component,x,y,positionTop)

Show the popup menu at the specified location. If positionTop is true, and there is enough room available, then popup menu's bottom - left corner is ending at the specified coordinates; x, y values are relative to top-left corner of the component. By default, positionTop is false. If there is not enough space above or under the component, the behavior is undefined (the browser will decide how menu is displayed)

Example:

Parameters:

  • runtimecomponent component The component where this popup is linked in

  • int x The x of the popup

  • int y The y coordinate of the popup

  • boolean [positionTop] The positionTop where to show the popup (default false)


show(event)

Show the popup menu relative to the event's source

Example:

Parameters:

  • JSEvent event Event related to Popup


show(x,y)

Show the popup menu at the specified location

Example:

Parameters:

  • int x The x of the popup

  • int y The y coordinate of the popup


RadioButton

scripting type: CustomType<window.RadioButton>

extends: MenuItem


Last updated

Was this helpful?