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

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.

主站蜘蛛池模板: 旺苍县| 靖边县| 淄博市| 南京市| 咸阳市| 麻城市| 侯马市| 东安县| 汨罗市| 宜兰市| 高唐县| 定边县| 洪洞县| 昔阳县| 常州市| 乌兰察布市| 大关县| 平南县| 竹北市| 金塔县| 健康| 贵州省| 平顺县| 额尔古纳市| 博罗县| 志丹县| 平顶山市| 济宁市| 衡阳市| 佛坪县| 新沂市| 勃利县| 丽江市| 伊金霍洛旗| 二连浩特市| 博罗县| 澄江县| 巨野县| 江川县| 弥渡县| 石阡县|