触控板
进程:
选项
对象items
(TouchBarButton | | TouchBarGroup | | TouchBarPopover | | TouchBarSegmentedControl | | TouchBarSpacer)escapeItem
(TouchBarButton | | TouchBarGroup | | TouchBarPopover | | TouchBarSegmentedControl | | TouchBarSpacer | 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使用情况。
A typeof TouchBarButton
reference to the TouchBarButton
class.
TouchBarColorPicker
TouchBarGroup
A reference to the TouchBarGroup
class.
A typeof TouchBarLabel
reference to the TouchBarLabel
class.
TouchBarPopover
A reference to the TouchBarPopover
class.
A typeof TouchBarScrubber
reference to the TouchBarScrubber
class.
A reference to the TouchBarSegmentedControl
class.
A typeof TouchBarSpacer
reference to the TouchBarSpacer
class.
TouchBarOtherItemsProxy
A reference to the TouchBarOtherItemsProxy
class.
在TouchBar
的实例中有以下属性可用:
TouchBarItem
设置的内容将替换掉Touch bar中的“esc”按钮 将该项设为null
以使用默认的”esc”按钮 修改这个值将立即更新Touch bar中的返回按钮
下面是一个带有一个按钮和若干文本的简易Touch bar老虎机游戏示例
- 将上述文件保存到您的电脑上,并命名为
touchbar.js
- 通过
npm install electron
来安装 Electron - 在 Electron 中运行示例:
接下来这个应用会在你的Touch bar (或者Touch bar模拟器) 上运行,你将能看到一个Electron窗口