Touch Bar 按钮
类:TouchBarButton¶
在触控栏中为原生 macOS 应用创建一个按钮。
进程:主进程
此类不会从 'electron' 模块中导出。它仅作为 Electron API 中其他方法的返回值可用。
new TouchBarButton(options)¶
optionsObjectlabelstring (optional) - 按钮文本。accessibilityLabelstring (optional) - 供 VoiceOver 等屏幕阅读器使用的按钮简短描述。backgroundColorstring (optional) - 按钮背景色(十六进制格式),例如#ABCDEF。iconNativeImage | string (optional) - 按钮图标。iconPositionstring (optional) - 可以为left、right或overlay。默认为overlay。clickFunction (optional) - 按钮被点击时要调用的函数。enabledboolean (optional) - 按钮是否处于启用状态。默认为true。
定义 accessibilityLabel 时,请确保你已考虑 macOS 的最佳实践。
实例属性¶
以下属性可用于 TouchBarButton 的实例:
touchBarButton.accessibilityLabel¶
一个 string,表示按钮的屏幕阅读器可读描述。只有在未设置 label 时,屏幕阅读器才会读取该描述。
touchBarButton.label¶
一个 string,表示按钮当前显示的文本。更改此值会立即更新触控栏中的按钮。
touchBarButton.backgroundColor¶
一个 string 十六进制颜色代码,表示按钮当前的背景色。更改此值会立即更新触控栏中的按钮。
touchBarButton.icon¶
一个 NativeImage,表示按钮当前的图标。更改此值会立即更新触控栏中的按钮。
touchBarButton.iconPosition¶
一个 string - 可以为 left、right 或 overlay。默认为 overlay。
touchBarButton.enabled¶
一个 boolean,表示按钮是否处于启用状态。
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 el/electron