类: TouchBarButton
为mac os应用在touch bar中创建一个按钮组件
进程:主进程
new TouchBarButton(options)
选项
对象label
String (可选) 按钮文本。accessibilityLabel
String (optional) - A short description of the button for use by screenreaders like VoiceOver.backgroundColor
String (可选) - 按钮背景颜色以十六进制格式,例如#ABCDEF
。icon
NativeImage | String (optional) - Button icon.iconPosition
String (可选) - 可以是left
、right
或overlay
。 Defaults tooverlay
.click
function (可选) - 单击按钮时调用的函数。enabled
Boolean (optional) - Whether the button is in an enabled state. 默认值为true
。
When defining accessibilityLabel
, ensure you have considered macOS best practices.
实例属性
下面的这些是TouchBarButton
中的属性:
touchBarButton.accessibilityLabel
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
A String
representing the button’s current text. Changing this value immediately updates the button in the touch bar.
touchBarButton.backgroundColor
A String
hex code representing the button’s current background color. Changing this value immediately updates the button in the touch bar.
touchBarButton.icon
A NativeImage
representing the button’s current icon. Changing this value immediately updates the button in the touch bar.
touchBarButton.iconPosition
A String
- Can be left
, right
or overlay
. Defaults to overlay
.
touchBarButton.enabled
A Boolean
representing whether the button is in an enabled state.