官术网_书友最值得收藏!

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:

  1. 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.
  2. 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' }
]
}
  1. 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.

主站蜘蛛池模板: 昭苏县| 马公市| 裕民县| 桂东县| 明溪县| 宜宾市| 沙雅县| 昌江| 文水县| 通城县| 龙川县| 新蔡县| 九龙坡区| 西青区| 芜湖县| 马鞍山市| 平顶山市| 扶沟县| 浦江县| 太湖县| 沙河市| 西和县| 商洛市| 汕头市| 晋江市| 东乡| 乐亭县| 剑川县| 开阳县| 三明市| 师宗县| 荥阳市| 东乌珠穆沁旗| 集贤县| 石泉县| 涟水县| 江口县| 衡山县| 卢龙县| 子长县| 广宗县|