Skip to main content

Class: TouchBarColorPicker

Class: TouchBarColorPicker

Create a color picker 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 TouchBarColorPicker(options)

  • options Object
    • availableColors string[] (optional) - Array of hex color strings to appear as possible colors to select.十六进制颜色字符串的数组,显示为要选择的可能颜色。
    • selectedColor string (optional) - The selected hex color in the picker, i.e #ABCDEF.选择器中选定的十六进制颜色,即#ABCDEF
    • change Function (optional) - Function to call when a color is selected.选择颜色时要调用的函数。
      • color string - The color that the user selected from the picker.用户从选择器中选择的颜色。

Instance Properties实例属性

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

touchBarColorPicker.availableColors

A string[] array representing the color picker's available colors to select. 一个string[]数组,表示要选择的颜色选择器的可用颜色。Changing this value immediately updates the color picker in the touch bar.更改此值会立即更新触摸栏中的颜色选择器。

touchBarColorPicker.selectedColor

A string hex code representing the color picker's currently selected color. 一个string,表示颜色选择器当前所选颜色的十六进制代码。Changing this value immediately updates the color picker in the touch bar.更改此值会立即更新触摸栏中的颜色选择器。