Skip to main content

Class: TouchBarLabel

Class: TouchBarLabel

Create a label in the touch bar for native macOS applications在触摸条中为本机macOS应用程序创建标签

Process:进程:Main
This class is not exported from the 'electron' module. 此类不是从'electron'模块导出的。It is only available as a return value of other methods in the Electron API.它只能作为Electron API中其他方法的返回值使用。

new TouchBarLabel(options)

  • options Object
    • label string (optional) - Text to display.要显示的文本。
    • accessibilityLabel string (optional) - A short description of the button for use by screenreaders like VoiceOver.按钮的简短说明,供VoiceOver等屏幕阅读器使用。
    • textColor string (optional) - Hex color of text, i.e #ABCDEF.文本的十六进制颜色,即#ABCDEF

When defining accessibilityLabel, ensure you have considered macOS best practices.在定义accessibilityLabel时,请确保您考虑了macOS的最佳实践

Instance Properties实例属性

The following properties are available on instances of TouchBarLabel:TouchBarLabel实例上提供了以下属性:

touchBarLabel.label

A string representing the label's current text. 表示标签的当前文本的stringChanging this value immediately updates the label in the touch bar.更改此值会立即更新触摸条中的标签。

touchBarLabel.accessibilityLabel

A string representing the description of the label to be read by a screen reader.一个string,表示要由屏幕阅读器读取的标签的描述。

touchBarLabel.textColor

A string hex code representing the label's current text color. 一个string,表示标签当前文本颜色的十六进制代码。Changing this value immediately updates the label in the touch bar.更改此值会立即更新触摸条中的标签。