- Electron Projects
- Denys Vuika
- 253字
- 2021-06-24 12:14:37
Sending messages between processes
Let's take a closer look at keyboard handling with our editor. By default, the SimpleMDE component provides support for most common editing shortcuts, such as the following:
- Cmd + B (Mac) or Ctrl + B (PC) to toggle the bold feature
- Cmd + H (Mac) or Ctrl + H (PC) to toggle the heading feature
- Cmd + I (Mac) or Ctrl + I (PC) to toggle the italics feature
The application menu isn't part of the web page. Therefore, we need a way to handle clicks and let the web page know that something has happened, or to trigger some code in JavaScript.
As you already know, the Electron framework is a combination of Chromium (rendering process) and Node.js (main process). Those processes are running side by side but isolated, and the only way to communicate between both processes is by sending messages.
This is why we are going to build the following data flow. The users of your application should get the Edit menu with the Bold item. Every time the Bold menu item is clicked, the Node.js (main process) handles the keyboard event and sends the message to the web page (rendering process) that the user wants to toggle the Bold feature for. Through JavaScript, the web page invokes the underlying functionality in the markdown editor component it uses.
- 數(shù)據(jù)庫系統(tǒng)原理及MySQL應(yīng)用教程(第2版)
- ASP.NET MVC4框架揭秘
- Mastering Objectoriented Python
- OpenCV實例精解
- Learning RabbitMQ
- 數(shù)據(jù)結(jié)構(gòu)習(xí)題精解(C語言實現(xiàn)+微課視頻)
- NativeScript for Angular Mobile Development
- Microsoft System Center Orchestrator 2012 R2 Essentials
- 程序員修煉之道:通向務(wù)實的最高境界(第2版)
- Learning DHTMLX Suite UI
- Mastering JavaScript High Performance
- Salesforce Reporting and Dashboards
- 區(qū)塊鏈技術(shù)與應(yīng)用
- Kotlin開發(fā)教程(全2冊)
- 會當凌絕頂:Java開發(fā)修行實錄