跳转到主要内容

类:TouchBarScrubber

Class: TouchBarScrubber

创建一个 scrubber(可滚动选择器)

进程:主进程
此类未从 'electron' 模块导出。它仅作为 Electron API 中其他方法的返回值可用。

new TouchBarScrubber(options)

  • options Object
    • items ScrubberItem[] - 要放置在此 scrubber 中的项目数组。
    • select Function (optional) - 当用户点击一个非最后点击的项目时调用。
      • selectedIndex Integer - 用户选择的项目索引。
    • highlight Function (optional) - 当用户点击任何项目时调用。
      • highlightedIndex Integer - 用户触摸的项目索引。
    • selectedStyle string (optional) - 选定项目样式。可以是 background, outlinenone。默认为 none
    • overlayStyle string (optional) - 选定覆盖项目样式。可以是 background, outlinenone。默认为 none
    • showArrowButtons boolean (optional) - 是否显示箭头按钮。默认为 false,仅当 items 非空时显示。
    • mode string (optional) - 可以是 fixedfree。默认为 free
    • continuous boolean (optional) - 默认为 true

实例属性

TouchBarScrubber 实例可用的以下属性

touchBarScrubber.items

一个 ScrubberItem[] 数组,表示此 scrubber 中的项目。更新此值将立即更新 touch bar 中的控件。更新此数组中的深层属性不会更新 touch bar

touchBarScrubber.selectedStyle

一个 string,表示 scrubber 中选定项目应具有的样式。更新此值将立即更新 touch bar 中的控件。可能的值

  • background - 映射到 [NSScrubberSelectionStyle roundedBackgroundStyle]
  • outline - 映射到 [NSScrubberSelectionStyle outlineOverlayStyle]
  • none - 移除所有样式。

touchBarScrubber.overlayStyle

一个 string,表示 scrubber 中选定项目应具有的样式。此样式将覆盖在 scrubber 项目之上,而不是放在其后面。更新此值将立即更新 touch bar 中的控件。可能的值

  • background - 映射到 [NSScrubberSelectionStyle roundedBackgroundStyle]
  • outline - 映射到 [NSScrubberSelectionStyle outlineOverlayStyle]
  • none - 移除所有样式。

touchBarScrubber.showArrowButtons

一个 boolean,表示是否在此 scrubber 中显示左/右选择箭头。更新此值将立即更新 touch bar 中的控件。

touchBarScrubber.mode

一个 string,表示此 scrubber 的模式。更新此值将立即更新 touch bar 中的控件。可能的值

  • fixed - 映射到 NSScrubberModeFixed
  • free - 映射到 NSScrubberModeFree

touchBarScrubber.continuous

一个 boolean,表示此 scrubber 是否连续。更新此值将立即更新 touch bar 中的控件。