类:TouchBarButton
类:TouchBarButton
¥Class: TouchBarButton
在触摸栏中为原生 macOS 应用创建一个按钮
¥Create a button in the touch bar for native macOS applications
进程:主进程
该类不是从 'electron' 模块导出的。它仅可用作 Electron API 中其他方法的返回值。
¥Process: Main
This class is not exported from the 'electron' module. It is only available as a return value of other methods in the Electron API.
new TouchBarButton(options)
定义 accessibilityLabel 时,请确保你已考虑 macOS 最佳实践。
¥When defining accessibilityLabel, ensure you have considered macOS best practices.
实例属性
¥Instance Properties
以下属性在 TouchBarButton 的实例上可用:
¥The following properties are available on instances of TouchBarButton:
touchBarButton.accessibilityLabel
string 代表屏幕阅读器要读取的按钮的描述。如果未设置标签,则仅由屏幕阅读器读取。
¥A string representing the description of the button to be read by a screen reader. Will only be read by screen readers if no label is set.
touchBarButton.label
代表按钮当前文本的 string。更改此值会立即更新触摸栏中的按钮。
¥A string representing the button's current text. Changing this value immediately updates the button
in the touch bar.
touchBarButton.backgroundColor
代表按钮当前背景颜色的 string 十六进制代码。更改此值会立即更新触摸栏中的按钮。
¥A string hex code representing the button's current background color. Changing this value immediately updates
the button in the touch bar.
touchBarButton.icon
NativeImage 代表按钮的当前图标。更改此值会立即更新触摸栏中的按钮。
¥A NativeImage representing the button's current icon. Changing this value immediately updates the button
in the touch bar.
touchBarButton.iconPosition
A string - 可以是 left、right 或 overlay。默认为 overlay。
¥A string - Can be left, right or overlay. Defaults to overlay.
touchBarButton.enabled
boolean 代表按钮是否处于启用状态。
¥A boolean representing whether the button is in an enabled state.