- Electron Projects
- Denys Vuika
- 221字
- 2021-06-24 12:14:36
Providing menu separators
Let's stop for a moment. Traditionally, in large applications, developers collect menu items into logical groups so that it is much easier for end users to remember and use them.
The following is an example of the File menu from Visual Studio Code, which you are probably using right now to edit project files:

The keyboard shortcuts may differ, depending on the platform you are using, but the structure should be the same with all operating systems.
Note how developers group multiple items into separate areas. If you want to separate two menu items, follow these steps:
- You can use an extra entry that has the type attribute set to separator. This instructs Electron to render a horizontal line to separate items visually.
- Update the code for your Debugging menu so that it looks as follows:
{
label: 'Debugging',
submenu: [
{
label: 'Dev Tools',
role: 'toggleDevTools'
},
{ type: 'separator' },
{ role: 'reload' }
]
}
- Restart the application. Inside the Debugging menu item, you should see two entries: Dev Tools and Reload:

Notice How the horizontal line separates both entries. This is our separator role in action, and you can use as many separators as you like in your menus.
Now, let's learn how Electron handles keyboard shortcuts, also known as accelerators, and key combinations.
- Docker and Kubernetes for Java Developers
- C程序設計簡明教程(第二版)
- Java高并發核心編程(卷2):多線程、鎖、JMM、JUC、高并發設計模式
- Java面向對象軟件開發
- 青少年軟件編程基礎與實戰(圖形化編程三級)
- HBase從入門到實戰
- DevOps Automation Cookbook
- Python程序設計案例教程
- JavaScript:Moving to ES2015
- 程序設計基礎教程:C語言
- 大學計算機基礎實驗指導
- Access 2010數據庫應用技術(第2版)
- Android項目實戰:手機安全衛士開發案例解析
- Fastdata Processing with Spark
- Appcelerator Titanium:Patterns and Best Practices