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

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.

主站蜘蛛池模板: 柳州市| 白水县| 长汀县| 海林市| 保康县| 大同市| 景德镇市| 太保市| 缙云县| 涿州市| 新源县| 内丘县| 普安县| 呼图壁县| 安溪县| 松江区| 施甸县| 万年县| 河曲县| 龙江县| 呼图壁县| 城口县| 寿光市| 咸阳市| 彰化县| 邵武市| 贵溪市| 萍乡市| 上思县| 柳江县| 桃园县| 类乌齐县| 临泉县| 轮台县| 巨鹿县| 金昌市| 贺兰县| 大城县| 德格县| 叙永县| 平遥县|