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

  • 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:

  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.

主站蜘蛛池模板: 芦溪县| 合水县| 凌云县| 东海县| 连平县| 西乡县| 沙田区| 抚顺市| 麦盖提县| 界首市| 儋州市| 修武县| 泰安市| 义马市| 商城县| 兰溪市| 鄱阳县| 临泉县| 静宁县| 遂宁市| 成都市| 高唐县| 和林格尔县| 巴中市| 阳信县| 迁安市| SHOW| 区。| 厦门市| 时尚| 新乡市| 盘锦市| 象州县| 张家港市| 天祝| 珠海市| 富裕县| 蒙自县| 澄江县| 西青区| 稷山县|