NGDesktop UI (ref)
(part of package 'NGDesktop UI')
You can access it in code via: plugins.ngdesktopui
Properties
API
addCheckBox(index,text,callback,checked,position,itemIndex)
Add a checkbox to the specified menu. NOTE: when adding the checkbox to an existing menuitem, that menuitem will turn from type "normal" to type "submenu". If a callback has been set previously, that callback will no longer be called.
Parameters:
{Number} index - menu index
{String} text - checkbox label
{Function} callback - callback function to call. The callback function will receive:- text of the clicked item- type of the clicked item ("normal", "radio", "checkbox")- checked value for checkboxes and radio buttons, otherwise undefined
{Boolean} [checked] - checkbox initial status (unchecked by default)
{Number} [position] - insert position
{Number} [itemIndex] - submenu index; when specified the position is relative to this submenu
Returns: Number - the index of the added checkbox
addDevToolsMenu()
Add Developer Tools menu to the menu bar
Use it just for debugging. Remove any call to this function once you're done.
Returns: Number - the index of the added menu or -1 if nothing has changed
addMenu(text,index)
Add new menu to the menu bar
Parameters:
Returns: Number - the index of the added menu
addMenuItem(index,text,callback,position,itemIndex)
Add menu items to existing menu. NOTE: when adding an item to an existing menuitem, that menuitem will turn from type "normal" to type "submenu". If a callback has been set previously, that callback will no longer be called.
Parameters:
{Number} index - menu index
{String} text - menuitem text
{Function} callback - callback function to call. The callback function will receive:- text of the clicked item- type of the clicked item ("normal", "radio", "checkbox")- checked value for checkboxes and radio buttons, otherwise undefined
{Number} [position] - insert position
{Number} [itemIndex] - submenu index; when specified the position is relative to this submenu
Returns: Number - the index of the added menu item
addRadioButton(index,text,callback,selected,position,itemIndex)
Add a radio button to the specified menu.
NOTE: when adding the checkbox to an existing menuitem, that menuitem will turn from type "normal" to type "submenu". If a callback has been set previously, that callback will no longer be called. NOTE: For the first added radio button in a group, the radio button will be selected ignoring the 'selected' param.
Parameters:
{Number} index - menu index
{String} text - checkbox label
{Function} callback - callback function to call. The callback function will receive:- text of the clicked item- type of the clicked item ("normal", "radio", "checkbox")- checked value for checkboxes and radio buttons, otherwise undefined
{Boolean} [selected] - initial selected status
{Number} [position] - insert position
{Number} [itemIndex] - submenu index; when specified the position is relative to this submenu
Returns: Number - the index of the added radio button
addRoleItem(index,role,text,position,itemIndex)
Add a menuitem with standard native system behavior. For a complete list of allowed values see: https://github.com/Servoy/ngdesktopui
Parameters:
{Number} index - menu index
{String} role - item role.
{String} [text] - menuitem text; when not specified the System will provide a standard (localized) one
{Number} [position] - insert position; when role is a predefined menu, this parameter is ignored;
{Number} [itemIndex] - submenu index; when specified the position is relative to this submenu; when role is a predefined menu this parameter is ignored
Returns: Number - the index of the added role item
addSeparator(index,position,itemIndex)
Add separator line to the specified menu
Parameters:
Returns: Number - the index of the added separator
closeBrowserView(id)
Closes a and destroys a previously created BrowserView by the given id.
Parameters:
{Number} id - the id of the view to close.
createBrowserView(x,y,width,height,url)
Creates a BrowserView (looks like an iframe) and adds this to the current window at the given coordinates with the given width and height. It returns and id that can be used to close/clean up this view later on, or to target that view to inject some javascript.
Parameters:
Returns: Number The id to target this view later on.
createTrayMenu()
Creates a system tray menu for the application. The tray menu allows users to interact with the application via a small icon in the system tray.
Example:
Returns: CustomType<ngdesktopui.trayMenu> The tray menu object that can be customized with title, tooltip, icon, and menu items.
getMenuCount()
Count menus from the menu bar.
Returns: Number The total number of menus currently present in the menu bar.
getMenuIndexByText(text)
Return the menu text at the specified position.
Parameters:
{String} text - the text to query for
Returns: Number - menu index containing the specified text; if not found return -1
getMenuItemIndexByText(index,text)
Get menuitem index from the specified menu
Parameters:
Returns: Number The index of the menu item with the specified text, or -1 if not found.
getMenuItemText(index,itemIndex)
Get menuitem text from the specified menu
Parameters:
Returns: String The text of the specified menu item, or null if the index is out of range.
getMenuItemsCount(index,itemIndex)
Count menu items for the specified menu
Parameters:
Returns: Number The number of menu items in the specified menu or submenu.
getMenuText(index)
Return the menu text from the specified menu position.
Parameters:
{Number} index The index to query for
Returns: String - menu's text; if index is out of range - null is returned
getWindowSize()
Get window size
Returns: Array<Number> - an array containing window's width and height
getZoomFactor()
Get the zoom factor of the current window
Returns: Number The zoom factor of the current window
hideWindow()
Hide the window
injectJSIntoBrowserView(id,js,callback)
Injects the given javascript into the content of the BrowserView of the given id. The javascript can be a function declaration that is then called later on. The last statement return value is given back to the callback as a first argument. If something goes wrong then the callback is called where the first argument is null and a second argument has the message of the exception.
Example:
Parameters:
isFullScreen()
Return true if window is in full screen state
Returns: Boolean True if the window is currently in full-screen mode; otherwise, false.
isMaximized()
Return true if window is in maximized state
Returns: Boolean True if the window is currently maximized; otherwise, false.
isMinimized()
Return true if window is in minimized state
Returns: Boolean True if the window is currently minimized; otherwise, false.
isNormal()
Return true whether the window is in normal state (not maximized, not minimized, not in fullscreen mode)
Returns: Boolean True if the window is in its default (normal) state; otherwise, false.
isVisible()
Return true if window is in visible to the user
Returns: Boolean True if the window is currently visible to the user; otherwise, false.
maximizeWindow()
Maximize the window
minimizeWindow()
Minimize the window
registerOnCloseMethod(callback)
Register callback to be executed before closing ngdesktop
Parameters:
{Function} callback - function to be executed before closing ngdesktop. Must return a boolean value: true if ngdesktop will close; false if ngdesktop will not close
Returns: Boolean - whether function executed succesfully or not
removeAllMenuItems(index,itemIndex)
Cleanup the specified menu
Parameters:
removeAllMenus()
Cleanup the menubar. For MacOS that means to display a minimal menu
removeMenu(index)
Delete menu from the specified position from the menu bar
Parameters:
{Number} index - menu position to be deleted
removeMenuItem(index,position,itemIndex)
Removes a menu item from an existing menu. NOTE: when the last item from a submenu is removed, that submenu will turn from type "submenu" to type "normal". If a callback has been set previously for the item, that callback will be called from then on.
Parameters:
resetMenuToDefault()
Reset ngdesktop menu to default
restoreWindow()
Restore the window
setFullScreen(flag)
Set window to full screen mode
Parameters:
{Boolean} flag If true, sets the window to full-screen mode; if false, exits full-screen mode.
setMenuBarVisibility(visible)
Show/hide menubar visibility. This function is working only on Windows/Linux
Parameters:
{Boolean} visible If true, the menu bar will be shown; if false, it will be hidden.
setWindowSize(width,height)
Set window size to the specified dimensions
Parameters:
setZoomFactor(factor)
Set the zoom factor of the current window 1 == 100%. 0.5 == 50%.
Parameters:
{Number} factor (values greater than 0.0 and smaller or equal to 5.0)
Returns: Boolean True if the zoom factor was successfully set; otherwise, false.
showWindow()
Show and gives focus to the window
unmaximizeWindow()
Unmaximize the window
unregisterOnCloseMethod()
Unregister the callback to be executed before closing ngdesktop.
useDefaultBrowserForExternalLinks(flag)
Set the way external links will be handled from ngdesktop. When the flag parameter is set to: - true: open external links using OS default browser - false: open external links using a new ngdesktop window
Parameters:
{Boolean} flag If true, external links will open in the OS default browser; if false, they will open in a new ngdesktop window.
Types
trayMenu
scripting type: CustomType<ngdesktopui.trayMenu>
trayMenuItem
scripting type: CustomType<ngdesktopui.trayMenuItem>
Last updated
Was this helpful?