Process:
参数
对象items
(TouchBarButton | | TouchBarGroup | | TouchBarPopover | | TouchBarSegmentedControl | | TouchBarSpacer)[] (optional)escapeItem
( | TouchBarColorPicker | | TouchBarLabel | | TouchBarScrubber | | TouchBarSlider | | null) (可选的)
Creates a new touch bar with the specified items. Use BrowserWindow.setTouchBar
to add the TouchBar
to a window.
注意: TouchBar API目前为实验性质,以后的Electron版本可能会更改或删除。
提示:如果您没有带Touch Bar的MacBook,则可以使用 Touch Bar Simulator 来测试应用中的Touch Bar使用情况。
A typeof TouchBarButton
reference to the TouchBarButton
class.
TouchBarColorPicker
TouchBarGroup
A reference to the TouchBarGroup
class.
TouchBarLabel
A reference to the TouchBarLabel
class.
TouchBarPopover
A reference to the TouchBarPopover
class.
TouchBarScrubber
A reference to the class.
TouchBarSegmentedControl
A reference to the TouchBarSegmentedControl
class.
TouchBarSlider
TouchBarSpacer
A typeof TouchBarSpacer
reference to the TouchBarSpacer
class.
在TouchBar
的实例中有以下属性可用:
touchBar.escapeItem
TouchBarItem
设置的内容将替换掉Touch bar中的“esc”按钮 将该项设为null
以使用默认的”esc”按钮 修改这个值将立即更新Touch bar中的返回按钮
示例
下面是一个带有一个按钮和若干文本的简易Touch bar老虎机游戏示例
要运行上面的示例,您需要 (假设您已经在将要运行该示例的目录中打开了一个终端):
- 将上述文件保存到您的电脑上,并命名为
touchbar.js
- 通过
npm install electron
来安装 Electron