类:TouchBarButton
类:TouchBarButton
🌐 Class: TouchBarButton
在触控栏为原生 macOS 应用创建一个按钮
进程: 主进程
此类未从 'electron' 模块导出。它仅作为 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.