NGDesktop UI plugin
Welcome to the ngdesktopui wiki! This wiki provides comprehensive documentation to using the ngdesktopui web service. This service works with the NGDesktop Client as a bridge to execute client side calls dealing with UI from Servoy.
Getting Started
First import the service one of the release binaries or via Servoy's Web Package Manager.
Example Usage
The following code snippet is create a sample menu for NGDesktop:
function createTestMenu(event) {
}
function addRecentFiles(menuIndex, submenuIndex) {
}
The following issues has been discovered so far:
setMenuBarVisibility has no effect on MacOS. You can't hide a MacOS menu
removeAllMenus - for MacOS is display a minimal menu having the app name as Menu name and Quit option as menuItem
on macOS - the first menuName is always the app name: first addMenu(menuName) will not display the "menuName" but the app name. The name behind (which you will work with), still remain "menuName"
on MacOS - the checkboxes and radio buttons in menus are not correctly rendered. This seems to be a Chromium issue. Further investigation needed for this
When clicking on a radio button - it will be selected, and the previous radio buttons (from the adiacent radio items) will be deselected. However, calling multiple times addRadioButton(menuName, menuitemName, true) will add multiple selected radio buttons (they will unselect automatically when one radio button is selected). It is your responsability to call addRadioButton() with "selected" parameter set to true - only once. The same issue is true also for insertRadioButton
The following sample will create a custom tray menu for NG Desktop:
function createTrayMenu(event) {
}
function trayCallback(itemName, itemType, itemStatus) {
}
API Documentation
Callback function
The callback function is receiving the following parameters:
Params
Method Summary
addMenu
Add new menu to existing menubar
Params
removeMenu
Remove specified menu
Params
addDevToolsMenu
Add Developer Tools menu to the menu bar. Use it just for debugging. Remove any call to this function once you're done.
getMenuIndexByText
Return the index order of the menu (zero based index)
Params
getMenuText
Return the menu label
Params
getMenuCount
Count menus from the menubar
removeAllMenus
Cleanup the menubar. For Mac OS this means to display a minimal menu.
setMenuBarVisibility
Show/Hide menu bar. On MacOS this method has no effect
Params
removeAllMenuItems
Cleanup the specified menu
Params
addSeparator
Add a separator line
Params
addMenuItem
Add an item to the specified menu
Params
removeMenuItem
Delete an item
Params
getMenuItemsCount
Count items
Params
addCheckBox
Add a checkbox to the specified menu
Params
addRadioButton
Add a radio button to the specified menu. Note that the first added radio button in the group is alwasy selected regardless the 'selected' value There are no group creation method. A group consist from all adiacent radio buttons in a menu
Params
getMenuItemIndexByText
Get menuitem index from the specified menu
Params
getMenuItemText
Get menuitem label
Params
addRoleItem
Roles allow menu items to have predefined behaviors.
Params
It is best to specify role for any menu item that matches a standard role, rather than trying to manually implement the behavior using a callback function. The built-in role behavior will give the best native experience.
The role property can have following values:
undo
about - Trigger a native about panel (custom message box on Window, which does not provide its own).
redo
cut
copy
paste
pasteAndMatchStyle
selectAll
delete
minimize - Minimize current window.
close - Close current window.
quit - Quit the application.
reload - Reload the current window.
forceReload - Reload the current window ignoring the cache.
toggleDevTools - Toggle developer tools in the current window.
togglefullscreen - Toggle full screen mode on the current window.
resetZoom - Reset the focused page's zoom level to the original size.
zoomIn - Zoom in the focused page by 10%.
zoomOut - Zoom out the focused page by 10%.
fileMenu - Whole default "File" menu (Close / Quit)
editMenu - Whole default "Edit" menu (Undo, Copy, etc.).
viewMenu - Whole default "View" menu (Reload, Toggle Developer Tools, etc.)
windowMenu - Whole default "Window" menu (Minimize, Zoom, etc.).
The following additional roles are available on macOS:
appMenu - Whole default "App" menu (About, Services, etc.)
hide - Map to the hide action.
hideOthers - Map to the hideOtherApplications action.
unhide - Map to the unhideAllApplications action.
startSpeaking - Map to the startSpeaking action.
stopSpeaking - Map to the stopSpeaking action.
front - Map to the arrangeInFront action.
zoom - Map to the performZoom action.
toggleTabBar - Map to the toggleTabBar action.
selectNextTab - Map to the selectNextTab action.
selectPreviousTab - Map to the selectPreviousTab action.
mergeAllWindows - Map to the mergeAllWindows action.
moveTabToNewWindow - Map to the moveTabToNewWindow action.
window - The submenu is a "Window" menu.
help - The submenu is a "Help" menu.
services - The submenu is a "Services" menu. This is only intended for use in the Application Menu and is not the same as the "Services" submenu used in context menus in macOS apps, which is not implemented in Electron.
recentDocuments - The submenu is an "Open Recent" menu.
clearRecentDocuments - Map to the clearRecentDocuments action.
createBrowserView
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.
Params
closeBrowserView
Closes a and destroys a previously created BrowserView by the given id.
Params
injectJSIntoBrowserView
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.
Params
createTrayMenu
Return a TrayMenu object type.
TrayMenu properties
Type | Name | Summary | Required string | title | tray menu title displayed next to the tray icon | Optional string | tooltip | just a tooptip | Optional byte[] | icon | icon to be displayed in the tray | Optional byte[] | pressedIcon | icon to be displayed when opening the tray (MacOS only) | Optional
TrayMenu api
This methods are available only through the TrayMenu object - trayMenu.method(params). The autocompletion is not yet available
Callback function
The callback function is receiving the following parameters:
addMenuItem
Add item to the tray menu
removeMenuItem
addCheckBox
addSeparator
Params
addRoleItem
Add a tray menu item with predefined (system) behavior. For details, check the documentation for the addRoleItem method above (for NG Desktop menu)
Params
done
When all desired changes to the tray menu are finalized, call this method for the changes to takes effect.
Example Usage
// open google.com var id = plugins.ngdesktopui.createBrowserView(100,200,700,500,"https://www.google.com/"); // get the value of the search field and return this. plugins.ngdesktopui.injectJSIntoBrowserView(id, "function test() { return document.getElementsByName('q')[0].value};test();", callback);
Last updated