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
closeFormPopup(retval)
Close the current form popup panel and assign the value to the configured data provider.
@example
@param {Object} retval return value for data provider
Parameters:
retval object
createFormPopup(form)
Create a form popup that can be filled with data and shown.
@example
@param form the form to show @return FormPopup
Parameters:
form form
Returns: FormPopup
createPopupMenu(menu,callback)
Creates a new popup menu, either empty, or initialized from an existing JSMenu.
@example
@param {JSMenu} [jsmenu] The JSMenu whose structure will be used to initialize the popup menu. @param {Function} [callback] The menu item click handler that will be set on all popup menu items @return {Popup}
Parameters:
Returns: Popup
createShortcut(shortcut,callback,contextFilter,arguments,consumeEvent)
Create a shortcut.
@example
@param {String} shortcut @param {String} methodName scopes.scopename.methodname or formname.methodname String to target the method to execute @param {String} contextFilter form or element name ( ng only - specified by formName.elementName); only triggers the shortcut when on this form/element @param arguments @param {Boolean} consumeEvent if true then the shotcut will consume the event and the default browser behavior will not be executed (default false)
Parameters:
shortcut string callback function contextFilter string (optional) arguments object [] (optional) consumeEvent boolean (optional)
Returns: boolean
getFormPopup(form)
It will return a FormPopup with the form passed as an argument or null.
@example
@param {RuntimeForm} form @return {FormPopup}
Parameters:
form form
Returns: FormPopup
removeShortcut(shortcut,contextFilter)
@clonedesc js_removeShortcut(String) @example
@param {String} shortcut @param {String} contextFilter form or element name ( ng only - specified by formName.elementName); only triggers the shortcut when on this form/element
Parameters:
Returns: boolean
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
@param {RuntimeComponent} elementToShowRelatedTo element to show related to or null to center in screen @param {RuntimeForm} form the form to show @param {Object} scope the scope to put retval into @param {String} dataproviderID the dataprovider of scope to fill @param {Number} width popup width @param {Number} height popup height @param {Number} x popup x location @param {Number} y popup y location @param {Boolean} showBackdrop whatever to show a dimmed backdrop under the popup @param {Boolean} doNotCloseOnClickOutside whether to close on not close the popup on clicking outside @param {Function} onClose a callback function that is being triggered once the formpopup window is being closed
Parameters:
component runtimecomponent form form scope object dataProviderID string width int (optional) height int (optional) x int (optional) y int (optional) showBackdrop boolean (optional) doNotCloseOnClickOutside boolean (optional) onClose function (optional)
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()
Set component form popup will be shown relative to. If null, will use coordinates or show at screen center.
Without an argument it is a getter, it returns the component.
@example
@param {RuntimeComponent} [component] the form to show @return The FormPopup itself if it's used as a setter or the component if no argument is given
Returns: runtimecomponent
component(component)
Set component form popup will be shown relative to. If null, will use coordinates or show at screen center.
Without an argument it is a getter, it returns the component.
@example
@param {RuntimeComponent} [component] the form to show @return The FormPopup itself if it's used as a setter or the component if no argument is given
Parameters:
component runtimecomponent
Returns: FormPopup
createFormPopup(form)
Create a form popup that can be filled with data and shown.
@example
@param form the form to show @return FormPopup
Parameters:
form form
Returns: FormPopup
dataprovider()
Set form popup dataprovider that will be set. If this is set, also scope needs to be specified.
Without an argument it is a getter, it returns the datprovider value
@example
@param {string} [dataprovider] form popup dataprovider @return The FormPopup itself if it's used as a setter or the dataprovider value if no argument is given
Returns: string
dataprovider(dataprovider)
Set form popup dataprovider that will be set. If this is set, also scope needs to be specified.
Without an argument it is a getter, it returns the datprovider value
@example
@param {string} [dataprovider] form popup dataprovider @return The FormPopup itself if it's used as a setter or the dataprovider value if no argument is given
Parameters:
dataprovider string
Returns: FormPopup
height()
Set form popup height. If not set, form design height will be used.
Without an argument it is a getter, it returns the height.
@example
@param {number} [height] form popup height @return The FormPopup itself if it's used as a setter or the height if no argument is given
Returns: int
height(height)
Set form popup height. If not set, form design height will be used.
Without an argument it is a getter, it returns the height.
@example
@param {number} [height] form popup height @return The FormPopup itself if it's used as a setter or the height if no argument is given
Parameters:
height int
Returns: FormPopup
onClose()
Get/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.
Without an argument it is a getter, it returns the onclose function value
@example
@param {function} [func] function that needs to be called when closed @return The FormPopup itself if it's used as a setter or the dataprovider value if no argument is given
Returns: function
onClose(onClose)
Get/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.
Without an argument it is a getter, it returns the onclose function value
@example
@param {function} [func] function that needs to be called when closed @return The FormPopup itself if it's used as a setter or the dataprovider value if no argument is given
Parameters:
onClose function
Returns: FormPopup
scope()
Set form popup scope that will be modified. If this is set, also dataprovider needs to be specified.
Without an argument it is a getter, it returns the scope object
@example
@param {object} scope form popup scope to modify @return The FormPopup itself if it's used as a setter or the dataprovider value if no argument is given
Returns: object
scope(scope)
Set form popup scope that will be modified. If this is set, also dataprovider needs to be specified.
Without an argument it is a getter, it returns the scope object
@example
@param {object} scope form popup scope to modify @return The FormPopup itself if it's used as a setter or the dataprovider value if no argument is given
Parameters:
scope object
Returns: FormPopup
show()
Show form popup using parameters that were set
@example
showBackdrop()
Set whether backdrop will be shown. Default value is false.
Without an argument it is a getter, it returns the backdrop value
@example
@param {boolean} [showBackdrop] form popup showBackdrop @return The FormPopup itself if it's used as a setter or the showBackdrop value if no argument is given
Returns: boolean
showBackdrop(showBackdrop)
Set whether backdrop will be shown. Default value is false.
Without an argument it is a getter, it returns the backdrop value
@example
@param {boolean} [showBackdrop] form popup showBackdrop @return The FormPopup itself if it's used as a setter or the showBackdrop value if no argument is given
Parameters:
showBackdrop boolean
Returns: FormPopup
width()
Set form popup width. If not set, form design width will be used.
Without an argument it is a getter, it returns the width.
@example
@param {number} [width] form popup width @return The FormPopup itself if it's used as a setter or the width if no argument is given
Returns: int
width(width)
Set form popup width. If not set, form design width will be used.
Without an argument it is a getter, it returns the width.
@example
@param {number} [width] form popup width @return The FormPopup itself if it's used as a setter or the width if no argument is given
Parameters:
width int
Returns: FormPopup
x()
Set form popup x location. The priority sequence for location is: related element, set location, center of screen.
Without an argument it is a getter, it returns the x.
@example
@param {number} [x] form popup x location @return The FormPopup itself if it's used as a setter or the x if no argument is given
Returns: int
x(x)
Set form popup x location. The priority sequence for location is: related element, set location, center of screen.
Without an argument it is a getter, it returns the x.
@example
@param {number} [x] form popup x location @return The FormPopup itself if it's used as a setter or the x if no argument is given
Parameters:
x int
Returns: FormPopup
y()
Set form popup y location. The priority sequence for location is: related element, set location, center of screen.
Without an argument it is a getter, it returns the y value
@example
@param {number} [y] form popup y location @return The FormPopup itself if it's used as a setter or the y value if no argument is given
Returns: int
y(y)
Set form popup y location. The priority sequence for location is: related element, set location, center of screen.
Without an argument it is a getter, it returns the y value
@example
@param {number} [y] form popup y location @return The FormPopup itself if it's used as a setter or the y value if no argument is given
Parameters:
y int
Returns: FormPopup
Menu
scripting type: CustomType<window.Menu> extends: BaseMenu
text
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
@param {Boolean} enabled
Parameters:
enabled boolean
setIcon(icon)
Set the icon of the menu.
@example
@param {Object} icon
Parameters:
icon object
setMnemonic(mnemonic)
Set the mnemonic of the selected menu.
@example
@param {String} mnemonic
Parameters:
mnemonic string
MenuItem
scripting type: CustomType<window.MenuItem>
enabled
Type: protected
Default Value: true
methodArguments
Type: object[]
name
Type: string
selected
Type: boolean
text
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.
@sample // add a new menu to the menubar var 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 var 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 variable originalTooltip = 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); @param {Object} key
Parameters:
key object
putClientProperty(key,value)
Sets the value for the specified client property key of the menu item/checkbox/radiobutton.
@example
@param {Object} key @param {Object} value
Parameters:
setAccelerator(accelerator)
Set the accelerator key of the menu item/checkbox/radiobutton.
@example
@param {String} accelerator @return s {MenuItem}
Parameters:
accelerator string
setBackgroundColor(bgColor)
Set the background color of the menu item/checkbox/radiobutton.
@param {String} bgColor
Parameters:
bgColor string
setForegroundColor(fgColor)
Set the foreground color of the menu item/checkbox/radiobutton.
@param {String} fgColor
Parameters:
fgColor string
setIcon(icon)
Set the icon of the menu item/checkbox/radiobutton.
@example
@param {Object} icon @return s {MenuItem}
Parameters:
icon object
setMethod(method,arguments)
Set the method for the menu item/checkbox/radiobutton.
@example
@param {Function} method @param {Array} arguments @return s {MenuItem}
Parameters:
setMnemonic(mnemonic)
Set the icon of the menu item/checkbox/radiobutton.
@example
@param {String} icon @return s {MenuItem}
Parameters:
mnemonic string
setVisible(visible)
Set the item visible.
@example
@param {Boolean} visible @return s {MenuItem}
Parameters:
visible boolean
Popup
scripting type: CustomType<window.Popup> extends: BaseMenu
cssClass
Type: string
show(component,positionTop)
Show the popup menu at the specified location this can have 3 different signatures:</br> 1> component param with optionally x,y and/or positionTop parameters</br> 2> event parameter</br> 3> x and y parameters</br> 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
@param {Object} component_or_event_or_x The component or the event or the x coordinate of the popup @param {Object} [x_or_y_or_positionTop] The x or y coordinate of the popup (depending on the first parameter) or positionTop @param {Number} [y] The y coordinate of the popup @param {Boolean} [positionTop] The positionTop where to show the popup (default false)
Parameters:
component runtimecomponent positionTop boolean (optional)
show(component,x,y,positionTop)
Show the popup menu at the specified location this can have 3 different signatures:</br> 1> component param with optionally x,y and/or positionTop parameters</br> 2> event parameter</br> 3> x and y parameters</br> 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
@param {Object} component_or_event_or_x The component or the event or the x coordinate of the popup @param {Object} [x_or_y_or_positionTop] The x or y coordinate of the popup (depending on the first parameter) or positionTop @param {Number} [y] The y coordinate of the popup @param {Boolean} [positionTop] The positionTop where to show the popup (default false)
Parameters:
component runtimecomponent x int y int positionTop boolean (optional)
show(event)
Show the popup menu at the specified location this can have 3 different signatures:</br> 1> component param with optionally x,y and/or positionTop parameters</br> 2> event parameter</br> 3> x and y parameters</br> 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
@param {Object} component_or_event_or_x The component or the event or the x coordinate of the popup @param {Object} [x_or_y_or_positionTop] The x or y coordinate of the popup (depending on the first parameter) or positionTop @param {Number} [y] The y coordinate of the popup @param {Boolean} [positionTop] The positionTop where to show the popup (default false)
Parameters:
event JSEvent
show(x,y)
Show the popup menu at the specified location this can have 3 different signatures:</br> 1> component param with optionally x,y and/or positionTop parameters</br> 2> event parameter</br> 3> x and y parameters</br> 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
@param {Object} component_or_event_or_x The component or the event or the x coordinate of the popup @param {Object} [x_or_y_or_positionTop] The x or y coordinate of the popup (depending on the first parameter) or positionTop @param {Number} [y] The y coordinate of the popup @param {Boolean} [positionTop] The positionTop where to show the popup (default false)
Parameters:
RadioButton
scripting type: CustomType<window.RadioButton> extends: MenuItem
Last updated