触控板

    进程:主进程

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

    注意: TouchBar API目前为实验性质,可能会更改或删除。

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

    TouchBarButton

    A reference to the TouchBarButton class.

    TouchBarColorPicker

    TouchBarGroup

    A typeof TouchBarGroup reference to the TouchBarGroup class.

    TouchBarLabel

    A typeof TouchBarLabel reference to the TouchBarLabel class.

    TouchBarPopover

    A typeof TouchBarPopover reference to the TouchBarPopover class.

    TouchBarScrubber

    A typeof TouchBarScrubber reference to the TouchBarScrubber class.

    A typeof TouchBarSegmentedControl reference to the TouchBarSegmentedControl class.

    TouchBarSlider

    TouchBarSpacer

    A reference to the TouchBarSpacer class.

    TouchBarOtherItemsProxy

    A reference to the TouchBarOtherItemsProxy class.

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

    touchBar.escapeItem

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

    示例

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

    1. 将上述文件保存到您的电脑上,并命名为 touchbar.js
    2. 通过 npm install electron 来安装 Electron
    3. 在 Electron 中运行示例:./node_modules/.bin/electron touchbar.js

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