进程:

Creates a new touch bar with the specified items. Use BrowserWindow.setTouchBar to add the TouchBar to a window.

Note: The TouchBar API is currently experimental and may change or be removed in future Electron releases.

Tip: If you don’t have a MacBook with Touch Bar, you can use Touch Bar Simulator to test Touch Bar usage in your app.

A reference to the TouchBarButton class.

A typeof TouchBarGroup reference to the TouchBarGroup class.

TouchBarLabel

A reference to the TouchBarLabel class.

A typeof TouchBarPopover reference to the TouchBarPopover class.

TouchBarScrubber

A reference to the TouchBarScrubber class.

A typeof TouchBarSegmentedControl reference to the TouchBarSegmentedControl class.

TouchBarSlider

TouchBarSpacer

A reference to the TouchBarSpacer class.

A typeof TouchBarOtherItemsProxy reference to the TouchBarOtherItemsProxy class.

TouchBar的实例中有以下属性可用:

touchBar.escapeItem

TouchBarItem设置的内容将替换掉Touch bar中的“esc”按钮 将该项设为null以使用默认的”esc”按钮 修改这个值将立即更新Touch bar中的返回按钮

示例

下面是一个带有一个按钮和若干文本的简易Touch bar老虎机游戏示例

  1. 将上述文件保存到您的电脑上,并命名为 touchbar.js
  2. 在 Electron 中运行示例:

接下来这个应用会在你的Touch bar (或者Touch bar模拟器) 上运行,你将能看到一个Electron窗口