{"id":1608,"date":"2018-05-21T18:30:00","date_gmt":"2018-05-21T18:30:00","guid":{"rendered":"https:\/\/xplicity.com\/?p=1608"},"modified":"2025-01-03T14:44:20","modified_gmt":"2025-01-03T11:44:20","slug":"part-3-creating-a-desktop-application-with-electron-angular-and-typescript-application-menu-system-tray-dialogs","status":"publish","type":"post","link":"https:\/\/xplicity.com\/part-3-creating-a-desktop-application-with-electron-angular-and-typescript-application-menu-system-tray-dialogs\/","title":{"rendered":"Part 3: Creating a desktop application with Electron, Angular and TypeScript: application menu, system tray, dialogs"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In the\u00a0<a href=\"https:\/\/xplicity.com\/part-2-creating-a-desktop-application-with-electron-angular-and-typescript-components-services-node-js-modules\/\" data-type=\"post\" data-id=\"1619\" target=\"_blank\" rel=\"noreferrer noopener\">previous article<\/a>\u00a0we created a simple Image Gallery desktop application. You\u2019ve learnt how to add components and services to an Electron-Angular desktop application and how to access Node.js modules from the application. In this article you will learn how to configure application menu and system tray, and how to call system dialogs (e.g. save dialog).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s extend the Image Gallery that we created in the last article.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We are going to configure application menu. We will leave only File, View and Help menus. The File menu will contain single Exit item, and View menu will contain Reload, Force Reload, Toggle Developer Tools, Actual Size, Zoom In and Zoom Out items. Help will contain About item, which will open About dialog.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We will add system tray icon that will have New Screenshot and Exit menu items. On New Screenshot click the application will take a screenshot of the screen, then it will display save dialog&nbsp;where a user can specify where to save the screenshot.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, we will extend the Gallery component by adding Open and Delete buttons to thumbnails of the images. The Open button will open the image in the default image viewing application. The Delete button will show a confirmation dialog&nbsp;and in case of approval will delete a selected image from the disk.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"678\" src=\"https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/1-image-gallery-system-tray-min-1346x891-1-1024x678.png\" alt=\"\" class=\"wp-image-1610\" srcset=\"https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/1-image-gallery-system-tray-min-1346x891-1-1024x678.png 1024w, https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/1-image-gallery-system-tray-min-1346x891-1-300x199.png 300w, https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/1-image-gallery-system-tray-min-1346x891-1-768x508.png 768w, https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/1-image-gallery-system-tray-min-1346x891-1.png 1346w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"684\" src=\"https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/2-image-gallery-about-min-1184x791-1-1024x684.png\" alt=\"\" class=\"wp-image-1611\" srcset=\"https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/2-image-gallery-about-min-1184x791-1-1024x684.png 1024w, https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/2-image-gallery-about-min-1184x791-1-300x200.png 300w, https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/2-image-gallery-about-min-1184x791-1-768x513.png 768w, https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/2-image-gallery-about-min-1184x791-1.png 1184w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">APPLICATION MENU<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Build menu<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create&nbsp;<strong>menu-helper.ts<\/strong>&nbsp;file in the&nbsp;<strong>electron<\/strong>&nbsp;folder. Declare&nbsp;<strong>MenuHelper<\/strong>&nbsp;class in the file. Create a class&nbsp;constructor that has&nbsp;<strong>browserWindow<\/strong>&nbsp;parameter of&nbsp;<strong>BrowserWindow<\/strong>&nbsp;type.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { BrowserWindow } from 'electron';\n\nexport class MenuHelper {\n  constructor(private browserWindow: BrowserWindow) {\n  }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">An application menu can be build using menu template. The menu template syntax is easy \u2013 it\u2019s just an array of menus and their submenus. Each menu item can have either a click event or a role assigned. Roles are predefined behaviors of menu items, e.g. if we assign the role \u201cquit\u201d to a menu item, it will quit the application on that menu item click. You can find the full list of roles&nbsp;<a href=\"https:\/\/electronjs.org\/docs\/api\/menu-item#roles\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.&nbsp;Also, it is possible to specify a type of menu item. It can be normal, separator, submenu, checkbox or radio.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s add the following menu template to the&nbsp;<strong>MenuHelper<\/strong>&nbsp;class:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>private mainMenuTemplate: MenuItemConstructorOptions&#91;] = &#91;\n  {\n    label: 'File',\n    submenu: &#91;\n      {\n        label: 'Exit',\n        role: 'close'\n      }\n    ]\n  },\n  {\n    label: 'View',\n    submenu: &#91;\n      {role: 'reload'},\n      {role: 'forcereload'},\n      {role: 'toggledevtools'},\n      {type: 'separator'},\n      {role: 'resetzoom'},\n      {role: 'zoomin'},\n      {role: 'zoomout'},\n      {type: 'separator'},\n      {role: 'togglefullscreen'}\n    ]\n  },\n  {\n    label: 'Help',\n    submenu: &#91;\n      {\n        label: 'About',\n        click: () =&gt; {\n          this.browserWindow.webContents.send('about');\n        }\n      }\n    ]\n  }\n];<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here we use roles for menu items of File and View menus. The Help -&gt; About menu item has click event attached. On its click it will send an asynchronous message (\u201cabout\u201d) to renderer process (our Angular app). From the Angular app we will listen for this message and will display the About dialog, when the message is received.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Add&nbsp;<strong>mainMenu<\/strong>&nbsp;property which will build menu object from the template and will return it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>get mainMenu(): Menu {\n  return Menu.buildFromTemplate(this.mainMenuTemplate);\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The full contents of the&nbsp;<strong>electron\/menu-helper.ts<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { BrowserWindow, MenuItemConstructorOptions, Menu } from 'electron';\n\nexport class MenuHelper {\n  constructor(private browserWindow: BrowserWindow) {\n  }\n\n  private mainMenuTemplate: MenuItemConstructorOptions&#91;] = &#91;\n    {\n      label: 'File',\n      submenu: &#91;\n        {\n          label: 'Exit',\n          role: 'close'\n        }\n      ]\n    },\n    {\n      label: 'View',\n      submenu: &#91;\n        {role: 'reload'},\n        {role: 'forcereload'},\n        {role: 'toggledevtools'},\n        {type: 'separator'},\n        {role: 'resetzoom'},\n        {role: 'zoomin'},\n        {role: 'zoomout'},\n        {type: 'separator'},\n        {role: 'togglefullscreen'}\n      ]\n    },\n    {\n      label: 'Help',\n      submenu: &#91;\n        {\n          label: 'About',\n          click: () =&gt; {\n            this.browserWindow.webContents.send('about');\n          }\n        }\n      ]\n    }\n  ];\n\n  get mainMenu(): Menu {\n    return Menu.buildFromTemplate(this.mainMenuTemplate);\n  }\n\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To set an application menu we need to call&nbsp;<strong>Menu.setApplicationMenu(menu: Menu)<\/strong>&nbsp;method after the&nbsp;<strong>ready<\/strong>&nbsp;event of&nbsp;<strong>app&nbsp;<\/strong>module. In the&nbsp;<strong>electron\/main.ts<\/strong>modify&nbsp;<strong>ready<\/strong>&nbsp;event listener. Replace the following line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>app.on('ready', createWindow);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>app.on('ready', () =&gt; {\n  createWindow();\n\n  const menuHelper = new MenuHelper(mainWindow);\n\n  Menu.setApplicationMenu(menuHelper.mainMenu);\n\n});<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The full contents of the&nbsp;<strong>electron\/main.ts<\/strong>&nbsp;file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { app, BrowserWindow, Menu } from 'electron';\nimport * as path from 'path';\nimport * as url from 'url';\nimport { MenuHelper } from '.\/menu-helper';\n\nlet mainWindow: Electron.BrowserWindow;\n\nfunction createWindow() {\n  \/\/ Create the browser window.\n  mainWindow = new BrowserWindow({\n    height: 600,\n    width: 800,\n  });\n\n  \/\/ and load the index.html of the app.\n  mainWindow.loadURL(url.format({\n      pathname: path.join(__dirname, 'index.html'),\n      protocol: 'file:',\n      slashes: true,\n  }));\n\n  \/\/ Open the DevTools.\n  mainWindow.webContents.openDevTools();\n\n  \/\/ Emitted when the window is closed.\n  mainWindow.on('closed', () =&gt; {\n    \/\/ Dereference the window object, usually you would store windows\n    \/\/ in an array if your app supports multi windows, this is the time\n    \/\/ when you should delete the corresponding element.\n    mainWindow = null;\n  });\n}\n\n\/\/ This method will be called when Electron has finished\n\/\/ initialization and is ready to create browser windows.\n\/\/ Some APIs can only be used after this event occurs.\napp.on('ready', () =&gt; {\n  createWindow();\n\n  const menuHelper = new MenuHelper(mainWindow);\n\n  Menu.setApplicationMenu(menuHelper.mainMenu);\n\n});\n\n\/\/ Quit when all windows are closed.\napp.on('window-all-closed', () =&gt; {\n  \/\/ On OS X it is common for applications and their menu bar\n  \/\/ to stay active until the user quits explicitly with Cmd + Q\n  if (process.platform !== 'darwin') {\n    app.quit();\n  }\n});\n\napp.on('activate', () =&gt; {\n  \/\/ On OS X it's common to re-create a window in the app when the\n  \/\/ dock icon is clicked and there are no other windows open.\n  if (mainWindow === null) {\n    createWindow();\n  }\n});\n\n\/\/ In this file you can include the rest of your app's specific main process\n\/\/ code. You can also put them in separate files and require them here.<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Adjust build commands<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">We\u2019ve just added the new&nbsp;<strong>electron\/menu-helper.ts<\/strong>&nbsp;file to the project, and therefore we need to add it to compilation process. In the&nbsp;<strong>package.json<\/strong>&nbsp;add a new&nbsp;<strong>electron-tsc<\/strong>&nbsp;command and modify existing&nbsp;<strong>electron-build<\/strong>&nbsp;and&nbsp;<strong>electron-build-prod<\/strong>&nbsp;commands:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"electron-tsc\": \"tsc electron\/main.ts --outDir dist -t es5 &amp;&amp; electron .\/dist\/main.js\",\n\"electron-build\": \"ng build &amp;&amp; npm run electron-tsc\",\n\"electron-build-prod\": \"ng build --prod &amp;&amp; npm run electron-tsc\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here we moved electron files compilation to the separate command&nbsp;<strong>electron-tsc<\/strong>. The command is called from&nbsp;<strong>electron-build<\/strong>&nbsp;and&nbsp;<strong>electron-build-prod<\/strong>commands.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check if it works:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm run electron-build<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"786\" height=\"593\" src=\"https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/3-application-menu-min.png\" alt=\"\" class=\"wp-image-1612\" srcset=\"https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/3-application-menu-min.png 786w, https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/3-application-menu-min-300x226.png 300w, https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/3-application-menu-min-768x579.png 768w\" sizes=\"auto, (max-width: 786px) 100vw, 786px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">You should see the updated application menu. All menu items should work except Help-&gt;About.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Create About dialog<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">We need an about dialog to show it on Help-&gt;About menu item click. So, let\u2019s create one. Run the following command to create component for the About dialog:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ng g component components\/about<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">We will use MatDialog from the Angular Material library to display the component as a dialog (popup). Add&nbsp;<strong>entryComponents<\/strong>&nbsp;array to the&nbsp;<strong>src\/app\/app.module.ts<\/strong>&nbsp;and add the just created&nbsp;<strong>AboutComponent<\/strong>&nbsp;to this array. Also, add the&nbsp;<strong>MatDialogModule<\/strong>&nbsp;to the&nbsp;<strong>imports<\/strong>&nbsp;array in the same file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>entryComponents: &#91;\n  AboutComponent\n],\nimports: &#91;\n  BrowserModule,\n  BrowserAnimationsModule,\n  MatListModule,\n  MatIconModule,\n  MatCardModule,\n  MatDialogModule\n],<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Check the&nbsp;<strong>MatDialogModule<\/strong>\u2019s import statement and add if needed:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import {MatListModule, MatIconModule, MatCardModule, MatDialogModule} from '@angular\/material';<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Inject&nbsp;<strong>MatDialogRef<\/strong>&nbsp;to the constructor of the&nbsp;<strong>AboutComponent<\/strong>&nbsp;class and declare public&nbsp;<strong>close()<\/strong>&nbsp;method that will close the dialog. The full contents of&nbsp;<strong>src\/app\/components\/about\/about.component.ts<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { Component, OnInit } from '@angular\/core';\nimport { MatDialogRef } from '@angular\/material';\n\n@Component({\n  selector: 'app-about',\n  templateUrl: '.\/about.component.html',\n  styleUrls: &#91;'.\/about.component.scss']\n})\nexport class AboutComponent implements OnInit {\n\n  constructor(private dialog: MatDialogRef) { }\n\n  ngOnInit() {\n  }\n\n  close() {\n    this.dialog.close();\n  }\n\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the template we just show title and image, both wrapped in div with click event attached (<strong>src\/app\/components\/about\/about.component.html<\/strong>):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;div (click)=\"close()\"&gt;\n  &lt;h2&gt;Electron Angular Image Viewerh2&gt;\n  &lt;img src=\"assets\/img\/xpl_640.png\" height=\"153\" width=\"550\"\/&gt;\ndiv&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Make &#8220;electron&#8221; module accessible from the Angular app<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">We need to use&nbsp;<strong>electron<\/strong>&nbsp;module for receiving messages that we send from the Help-&gt;About click event. To make the&nbsp;<strong>electron<\/strong>&nbsp;module accessible from our Angular app add the following line to&nbsp;<strong>src\/js\/modules.js<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>window.ELECTRON = require('electron');<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then, create a wrapper property for the&nbsp;<strong>window.ELECTRON<\/strong>&nbsp;variable in the&nbsp;<strong>RequiredModulesService<\/strong>&nbsp;(<strong>src\/app\/services\/required-modules.service.ts<\/strong>):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>get electron(): any {\n  return this.browserWindow.ELECTRON;\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Create Electron Menu service<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Electron Menu service will be responsible for receiving messages from Electron backend and invoking corresponding actions. Create the service with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ng g service services\/electron-menu<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add the&nbsp;<strong>ElectronMenuService<\/strong>&nbsp;to the providers array of the&nbsp;<strong>src\/app\/app.module.ts<\/strong>&nbsp;file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>providers: &#91;\n  RequiredModulesService,\n  FileService,\n  ElectronMenuService\n],<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Check the import statement and add it if needed:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { ElectronMenuService } from '.\/services\/electron-menu.service';<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The full contents of the service (<strong>src\/app\/services\/electron-menu.service.ts<\/strong>):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { Injectable, NgZone } from '@angular\/core';\nimport { RequiredModulesService } from '.\/required-modules.service';\nimport { MatDialog } from '@angular\/material';\nimport { AboutComponent } from '..\/components\/about\/about.component';\n\n@Injectable()\nexport class ElectronMenuService {\n\n  constructor(private requiredModulesService: RequiredModulesService,\n    private dialog: MatDialog, private ngZone: NgZone) {\n      requiredModulesService.electron.ipcRenderer.on('about', () =&gt; {\n        this.showAboutDialog();\n      });\n  }\n\n  showAboutDialog() {\n    this.ngZone.run(() =&gt; {\n      this.dialog.closeAll();\n      this.dialog.open(AboutComponent);\n    });\n  }\n\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here, we injected&nbsp;<strong>RequiredModulesService<\/strong>,&nbsp;<strong>MatDIalog<\/strong>&nbsp;and&nbsp;<strong>NgZone<\/strong>&nbsp;to the class. We added&nbsp;<strong>showAboutDialog<\/strong>&nbsp;method which opens the About dialog. Pay attention that the call wrapped into the ngZone.run() method. Running functions via Angular zone\u2019s&nbsp;<strong>run<\/strong>&nbsp;allows to reenter Angular zone from a task that was executed outside of the Angular zone (in our case Electron backend is outside of the Angular zone). In the constructor we use Electron\u2019s&nbsp;<strong>ipcRenderer<\/strong>&nbsp;module to receive messages from the Electron backend. Particularly, the&nbsp;<strong>ipcRendrer.on<\/strong>&nbsp;method listens for the \u201cabout\u201d message from the Electron backend and invokes function that opens About dialog when the message is received.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Inject the Electron Menu service to the App component (<strong>src\/app\/app.component.ts<\/strong>):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>constructor(private changeDetector: ChangeDetectorRef, electronMenuService: ElectronMenuService) {}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The injection will make sure that the constructor of the&nbsp;<strong>ElectronMenuService<\/strong>&nbsp;will be called and the service will start listening for messages from Electron backend.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Recompile the app, select Help-&gt;About menu and see the results:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm run electron-build<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"786\" height=\"593\" src=\"https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/4-about-dialog-min.png\" alt=\"\" class=\"wp-image-1613\" srcset=\"https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/4-about-dialog-min.png 786w, https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/4-about-dialog-min-300x226.png 300w, https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/4-about-dialog-min-768x579.png 768w\" sizes=\"auto, (max-width: 786px) 100vw, 786px\" \/><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">SYSTEM TRAY<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Build system tray menu<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Constructing of system tray\u2019s menu is similar to what we did for building of the application menu. Declare menu template in the MenuHelper class (<strong>electron\/menu-helper.ts<\/strong>):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>private trayMenuTemplate: MenuItemConstructorOptions&#91;] = &#91;\n  {\n    label: 'New screenshot',\n    click: () =&gt; {\n      this. browserWindow.webContents.send('screenshot');\n    }\n  },\n  {\n    label: 'Exit',\n    click: () =&gt; { app.quit(); }\n  }\n];<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The system tray menu contains two items \u201cNew screenshot\u201d and \u201cExit\u201d. \u201cNew screenshot\u201d sends the \u201cscreenshot\u201d message to the frontend, and \u201cExit\u201d just quits the app.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Make sure you added the import statement for the&nbsp;<strong>app<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { BrowserWindow, MenuItemConstructorOptions, Menu, app } from 'electron';<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add&nbsp;<strong>trayMenu<\/strong>&nbsp;property to the same class:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>get trayMenu() {\n  return Menu.buildFromTemplate(this.trayMenuTemplate);\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This builds the system tray menu object from the template and returns it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the&nbsp;<strong>electron\/main.ts<\/strong>&nbsp;file declare&nbsp;<strong>appIcon<\/strong>&nbsp;and&nbsp;<strong>iconPath<\/strong>&nbsp;variables:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>let appIcon: Tray;\nconst iconPath = path.join(__dirname, 'assets\/img\/x-icon.png');<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">in the&nbsp;<strong>&#8220;ready&#8221;<\/strong>&nbsp;event listener, instantiate&nbsp;<strong>appIcon<\/strong>&nbsp;variable, set icon path, tooltip, and context menu:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>appIcon = new Tray(iconPath);\nappIcon.setToolTip('Image Viewer');\nappIcon.setContextMenu(menuHelper.trayMenu);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Also make the application window a bit bigger and set the application icon:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mainWindow = new BrowserWindow({\n  height: 800,\n  width: 1200,\n  icon: iconPath\n});<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The full contents of the&nbsp;<strong>electron\/main.ts<\/strong>&nbsp;file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { app, BrowserWindow, Menu, Tray } from 'electron';\nimport * as path from 'path';\nimport * as url from 'url';\nimport { MenuHelper } from '.\/menu-helper';\n\nlet mainWindow: Electron.BrowserWindow;\nlet appIcon: Tray;\nconst iconPath = path.join(__dirname, 'assets\/img\/x-icon.png');\n\nfunction createWindow() {\n  \/\/ Create the browser window.\n  mainWindow = new BrowserWindow({\n    height: 800,\n    width: 1200,\n    icon: iconPath\n  });\n\n  \/\/ and load the index.html of the app.\n  mainWindow.loadURL(url.format({\n      pathname: path.join(__dirname, 'index.html'),\n      protocol: 'file:',\n      slashes: true,\n  }));\n\n  \/\/ Open the DevTools.\n  mainWindow.webContents.openDevTools();\n\n  \/\/ Emitted when the window is closed.\n  mainWindow.on('closed', () =&gt; {\n    \/\/ Dereference the window object, usually you would store windows\n    \/\/ in an array if your app supports multi windows, this is the time\n    \/\/ when you should delete the corresponding element.\n    mainWindow = null;\n  });\n}\n\n\/\/ This method will be called when Electron has finished\n\/\/ initialization and is ready to create browser windows.\n\/\/ Some APIs can only be used after this event occurs.\napp.on('ready', () =&gt; {\n  createWindow();\n\n  const menuHelper = new MenuHelper(mainWindow);\n\n  Menu.setApplicationMenu(menuHelper.mainMenu);\n\n  appIcon = new Tray(iconPath);\n  appIcon.setToolTip('Image Viewer');\n  appIcon.setContextMenu(menuHelper.trayMenu);\n\n\n});\n\n\/\/ Quit when all windows are closed.\napp.on('window-all-closed', () =&gt; {\n  \/\/ On OS X it is common for applications and their menu bar\n  \/\/ to stay active until the user quits explicitly with Cmd + Q\n  if (process.platform !== 'darwin') {\n    app.quit();\n  }\n});\n\napp.on('activate', () =&gt; {\n  \/\/ On OS X it's common to re-create a window in the app when the\n  \/\/ dock icon is clicked and there are no other windows open.\n  if (mainWindow === null) {\n    createWindow();\n  }\n});\n\n\/\/ In this file you can include the rest of your app's specific main process\n\/\/ code. You can also put them in separate files and require them here.<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Check the results:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm run electron-build<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"232\" height=\"84\" src=\"https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/5-system-tray-icon-min.png\" alt=\"\" class=\"wp-image-1614\"\/><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\">Screenshot service<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create Screenshot service that will be responsible for taking and saving screenshots.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ng g service services\/screenshot<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Inject&nbsp;<strong>RequiredModulesService<\/strong>&nbsp;to the service class (<strong>app\/services\/screenshot.service.ts<\/strong>):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>constructor(private requiredModulesService: RequiredModulesService) { }<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Declare helper variables:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>private screen = this.requiredModulesService.electron.screen;\nprivate desktopCapturer = this.requiredModulesService.electron.desktopCapturer;\nprivate remote = this.requiredModulesService.electron.remote;\nprivate shell = this.requiredModulesService.electron.shell;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add&nbsp;<strong>determineScreenshotSize<\/strong>&nbsp;method which calculates screenshot size based on primary display\u2019s resolution and DPI:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>private determineScreenshotSize() {\n  const screenSize = this.screen.getPrimaryDisplay().workAreaSize;\n  const maxDimension = Math.max(screenSize.width, screenSize.height);\n  return {\n    width: maxDimension * window.devicePixelRatio,\n    height: maxDimension * window.devicePixelRatio\n  };\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add&nbsp;<strong>takeScreenshot<\/strong>&nbsp;method:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>takeScreenshot() {\n  const screenshotSize = this.determineScreenshotSize();\n  const options = { types: &#91;'screen'], thumbnailSize: screenshotSize };\n  this.desktopCapturer.getSources(options, (error, sources) =&gt; {\n    if (error) {\n      console.error(error);\n      this.remote.dialog.showErrorBox('Error', error);\n    }\n\n    sources.filter(source =&gt; source.name === 'Entire screen' || source.name === 'Screen 1').forEach(source =&gt; {\n      this.remote.dialog.showSaveDialog({filters: &#91;{name: 'PNG Files', extensions: &#91;'png']}]}, (fileName) =&gt; {\n        if (fileName == null) { return; }\n        this.requiredModulesService.fs.writeFile(fileName, source.thumbnail.toPng(), writeError =&gt; {\n          if (writeError) {\n            console.error(writeError);\n            this.remote.dialog.showErrorBox('Error', writeError);\n          } else {\n            this.shell.openExternal(`file:\/\/${fileName}`);\n          }\n        });\n      });\n    });\n  });\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The method takes a screenshot, displays system\u2019s save dialog, saves the screenshot as a PNG file, and opens the saved picture in the default PNG image viewing application. In case of an error, it displays a modal dialog that shows the error message.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The full contents of&nbsp;<strong>app\/services\/screenshot.service.ts<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { Injectable } from '@angular\/core';\nimport { RequiredModulesService } from '.\/required-modules.service';\n\n@Injectable()\nexport class ScreenshotService {\n\n  private screen = this.requiredModulesService.electron.screen;\n  private desktopCapturer = this.requiredModulesService.electron.desktopCapturer;\n  private remote = this.requiredModulesService.electron.remote;\n  private shell = this.requiredModulesService.electron.shell;\n\n\n  constructor(private requiredModulesService: RequiredModulesService) { }\n\n  private determineScreenshotSize() {\n    const screenSize = this.screen.getPrimaryDisplay().workAreaSize;\n    const maxDimension = Math.max(screenSize.width, screenSize.height);\n    return {\n      width: maxDimension * window.devicePixelRatio,\n      height: maxDimension * window.devicePixelRatio\n    };\n  }\n\n  takeScreenshot() {\n    const screenshotSize = this.determineScreenshotSize();\n    const options = { types: &#91;'screen'], thumbnailSize: screenshotSize };\n    this.desktopCapturer.getSources(options, (error, sources) =&gt; {\n      if (error) {\n        console.error(error);\n        this.remote.dialog.showErrorBox('Error', error);\n      }\n\n      sources.filter(source =&gt; source.name === 'Entire screen' || source.name === 'Screen 1').forEach(source =&gt; {\n        this.remote.dialog.showSaveDialog({filters: &#91;{name: 'PNG Files', extensions: &#91;'png']}]}, (fileName) =&gt; {\n          if (fileName == null) { return; }\n          this.requiredModulesService.fs.writeFile(fileName, source.thumbnail.toPng(), writeError =&gt; {\n            if (writeError) {\n              console.error(writeError);\n              this.remote.dialog.showErrorBox('Error', writeError);\n            } else {\n              this.shell.openExternal(`file:\/\/${fileName}`);\n            }\n          });\n        });\n      });\n    });\n  }\n\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add the&nbsp;<strong>ScreenshotService<\/strong>&nbsp;to the&nbsp;<strong>providers<\/strong>&nbsp;array of the&nbsp;<strong>src\/app\/app.module.ts<\/strong>&nbsp;file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>providers: &#91;\n  RequiredModulesService,\n  FileService,\n  ElectronMenuService,\n  ScreenshotService\n],<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Check the import statement, and add it if needed:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { ScreenshotService } from '.\/services\/screenshot.service';<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Inject the&nbsp;<strong>ScreenchotService<\/strong>&nbsp;to the&nbsp;<strong>ElectronMenuService<\/strong>\u2018s class and add listener for the&nbsp;<strong>\u201escreenshot\u201c<\/strong>&nbsp;event to the constructor (<strong>src\/app\/services\/electron-menu-service.ts<\/strong>):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>requiredModulesService.electron.ipcRenderer.on('screenshot', () =&gt; {\n  this.screenshotService.takeScreenshot();\n});<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The full contents of&nbsp;<strong>src\/app\/services\/electron-menu.service.ts<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import { Injectable, NgZone } from '@angular\/core';\nimport { RequiredModulesService } from '.\/required-modules.service';\nimport { MatDialog } from '@angular\/material';\nimport { AboutComponent } from '..\/components\/about\/about.component';\nimport { ScreenshotService } from '.\/screenshot.service';\n\n@Injectable()\nexport class ElectronMenuService {\n\n  constructor(private requiredModulesService: RequiredModulesService,\n    private screenshotService: ScreenshotService,\n    private dialog: MatDialog, private ngZone: NgZone) {\n      requiredModulesService.electron.ipcRenderer.on('about', () =&gt; {\n        this.showAboutDialog();\n      });\n\n      requiredModulesService.electron.ipcRenderer.on('screenshot', () =&gt; {\n        this.screenshotService.takeScreenshot();\n      });\n  }\n\n  showAboutDialog() {\n    this.ngZone.run(() =&gt; {\n      this.dialog.closeAll();\n      this.dialog.open(AboutComponent);\n    });\n  }\n\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Recompile the app and try to take a screenshot using system tray menu:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm run electron-build<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"685\" src=\"https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/6-screenshot-save-dialog-min-1024x685.png\" alt=\"\" class=\"wp-image-1615\" srcset=\"https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/6-screenshot-save-dialog-min-1024x685.png 1024w, https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/6-screenshot-save-dialog-min-300x201.png 300w, https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/6-screenshot-save-dialog-min-768x514.png 768w, https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/6-screenshot-save-dialog-min.png 1186w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">After you click \u201cSave\u201d in the save dialog, the saved screenshot image file will be opened in the application associated with PNG extension.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"802\" height=\"563\" src=\"https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/7-saved-screenshot-min.png\" alt=\"\" class=\"wp-image-1616\" srcset=\"https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/7-saved-screenshot-min.png 802w, https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/7-saved-screenshot-min-300x211.png 300w, https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/7-saved-screenshot-min-768x539.png 768w\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" \/><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">OPEN AND DELETE IMAGE FUNCTIONALITY<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s extend our Gallery by adding Open and Delete buttons to thumbnails. We will use MatButton component from the Angular Material library, therefore we need to add&nbsp;<strong>MatButtonModule<\/strong>&nbsp;to the&nbsp;<strong>imports<\/strong>&nbsp;array in the&nbsp;<strong>src\/app\/app.module.ts<\/strong>&nbsp;file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>imports: &#91;\n  BrowserModule,\n  BrowserAnimationsModule,\n  MatListModule,\n  MatIconModule,\n  MatCardModule,\n  MatDialogModule,\n  MatButtonModule\n],<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Check the import statement and add it if needed:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import {MatListModule, MatIconModule, MatCardModule, MatDialogModule, MatButtonModule} from '@angular\/material';<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add two new methods to the File service (<strong>src\/app\/services\/file.services.ts<\/strong>) \u2013 one for opening a file, and other for deleting a file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>openFile(path: string) {\n  this.requiredModulesService.electron.shell.openItem(path);\n}\n\ndeleteFile(path: string) {\n  this.requiredModulesService.fs.unlink(path, error =&gt; {\n    console.error(error);\n  });\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Inject&nbsp;<strong>RequiredModulesService<\/strong>&nbsp;to the Gallery component\u2018s class (<strong>src\/app\/components\/gallery\/gallery.component.ts<\/strong>):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>constructor(private fileService: FileService,\n  private requiredModulesService: RequiredModulesService,\n  private changeDetector: ChangeDetectorRef) { }<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add&nbsp;<strong>openFile<\/strong>&nbsp;method to the same class:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>openFile(fileInfo: FileInfo) {\n  this.fileService.openFile(fileInfo.fullPath);\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The method is very simple \u2013 it&nbsp;just calls&nbsp;<strong>openFile<\/strong>&nbsp;method from the&nbsp;<strong>FileService<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also add&nbsp;<strong>deleteFile<\/strong>&nbsp;method:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>deleteFile(fileInfo: FileInfo) {\n  const dialog = this.requiredModulesService.electron.remote.dialog;\n  const currentWindow = this.requiredModulesService.electron.remote.getCurrentWindow();\n  dialog.showMessageBox(currentWindow, {\n    type: 'question',\n    buttons: &#91;'Yes', 'No'],\n    title: 'Confirm',\n    message: `Are you sure you want to delete ${fileInfo.name}?`\n  }, (choice) =&gt; {\n    if (choice === 0) {\n      this.fileService.deleteFile(fileInfo.fullPath);\n      const index = this.imageFiles.indexOf(fileInfo);\n      if (index !== -1) {\n        this.imageFiles.splice(index, 1);\n        this.changeDetector.detectChanges();\n      }\n    }\n  }\n  );\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The method displays confirmation dialog, and, in case of approval, calls&nbsp;<strong>deleteFile<\/strong>&nbsp;method from the File service, removes file from the&nbsp;<strong>imageFiles<\/strong>&nbsp;array, and tells Angular to detect changes. The&nbsp;<strong>remote<\/strong>&nbsp;module allows us to use Electron\u2019s main process modules (such as dialog) from the frontend (renderer process).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the Gallery component\u2019s template add \u201cOpen\u201d and \u201cDelete\u201d buttons with the appropriate events (<strong>src\/app\/components\/gallery\/gallery.component.html<\/strong>):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;mat-card-actions&gt;\n  &lt;button mat-button color=\"primary\" (click)=\"openFile(file)\"&gt;Openbutton&gt;\n  &lt;button mat-button color=\"warn\" class=\"float-right\" (click)=\"deleteFile(file)\"&gt;Deletebutton&gt;\nmat-card-actions&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The full contents of the&nbsp;<strong>src\/app\/components\/gallery\/gallery.component.html<\/strong>&nbsp;file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;div class=\"container\"&gt;\n  &lt;mat-card *ngFor=\"let file of imageFiles\" class=\"image-preview\"&gt;\n    &lt;mat-card-header&gt;\n      &lt;mat-card-title&gt;{{file.name}}mat-card-title&gt;\n    mat-card-header&gt;\n    &lt;img mat-card-image src=\"{{file.url}}\" alt=\"{{file.name}}\"&gt;\n    &lt;mat-card-actions&gt;\n      &lt;button mat-button color=\"primary\" (click)=\"openFile(file)\"&gt;Openbutton&gt;\n      &lt;button mat-button color=\"warn\" class=\"float-right\" (click)=\"deleteFile(file)\"&gt;Deletebutton&gt;\n    mat-card-actions&gt;\n  mat-card&gt;\ndiv&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add style for the float-right class to the global styles (<strong>src\/styles.scss<\/strong>):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.float-right {\n  float: right;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Recompile the app and check if it works:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm run electron-build<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"685\" src=\"https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/8-delete-dialog-min-1024x685.png\" alt=\"\" class=\"wp-image-1617\" srcset=\"https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/8-delete-dialog-min-1024x685.png 1024w, https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/8-delete-dialog-min-300x201.png 300w, https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/8-delete-dialog-min-768x514.png 768w, https:\/\/xplicity.com\/wp-content\/uploads\/2023\/07\/8-delete-dialog-min.png 1186w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\">CONCLUSION<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">We\u2019ve extended the Image Gallery desktop application. Now it has application menu and system tray icon with menu. Also, the application can take screenshots, open and delete image files.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You\u2019ve learnt how to configure menu, system tray, and handle menu events from the Angular side of the application. Besides that, you\u2019ve learnt how to take a screenshot and use system dialogs and call them from the frontend.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the\u00a0<a href=\"https:\/\/xplicity.com\/part-4-creating-a-desktop-application-with-electron-angular-and-typescript-application-distribution\/\" data-type=\"post\" data-id=\"1563\" target=\"_blank\" rel=\"noreferrer noopener\">next article<\/a>\u00a0you will learn how to distribute an Electron-Angular application.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The source code of this article\u2019s project is available&nbsp;<a href=\"https:\/\/gitlab.com\/atolvaisis\/electron-angular-pt3\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the\u00a0previous article\u00a0we created a simple Image Gallery desktop application. You\u2019ve learnt how to add components and services to an Electron-Angular desktop application and how to access Node.js modules from the application. In this article you will learn how to configure application menu and system tray, and how to call system dialogs (e.g. save dialog). [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1609,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-1608","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"acf":[],"_links":{"self":[{"href":"https:\/\/xplicity.com\/wp-json\/wp\/v2\/posts\/1608","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xplicity.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xplicity.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xplicity.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xplicity.com\/wp-json\/wp\/v2\/comments?post=1608"}],"version-history":[{"count":3,"href":"https:\/\/xplicity.com\/wp-json\/wp\/v2\/posts\/1608\/revisions"}],"predecessor-version":[{"id":2501,"href":"https:\/\/xplicity.com\/wp-json\/wp\/v2\/posts\/1608\/revisions\/2501"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xplicity.com\/wp-json\/wp\/v2\/media\/1609"}],"wp:attachment":[{"href":"https:\/\/xplicity.com\/wp-json\/wp\/v2\/media?parent=1608"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xplicity.com\/wp-json\/wp\/v2\/categories?post=1608"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xplicity.com\/wp-json\/wp\/v2\/tags?post=1608"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}