Combo Button 组合按钮 macos

标本可交互 —— 点点看。Specimen is live — try it.

Anatomy — every part, named解剖 —— 每个部件的名字

  1. 1 Primary action region主操作区域 NSComboButton.action

    “The main half that does the thing immediately” is the primary action region.

    「点了立刻执行的那半边」就是主操作区域。

    Prompt fragmentPrompt 片段

    the NSComboButton primary action region, with the main label performing the default action immediately

    NSComboButton 的主操作区域,主标签点击后立即执行默认操作

  2. 2 Menu disclosure region菜单披露区域 NSComboButton.menu

    “The separate little arrow attached to the button” is the menu disclosure region.

    「按钮上连着的那个独立小箭头」就是菜单披露区域。

    Prompt fragmentPrompt 片段

    the separate NSComboButton menu disclosure region, a narrow attached chevron target that opens the related NSMenu

    NSComboButton 独立的菜单披露区域:一个附着在旁边、窄窄的 chevron 点击目标,用来打开相关的 NSMenu

  3. 3 Split divider分体分隔线 NSComboButton.Style.split

    “The tiny line between the label and arrow” is the split divider.

    「标签和箭头之间那条小细线」就是分体分隔线。

    Prompt fragmentPrompt 片段

    the divider in NSComboButton.Style.split that visibly separates the primary action target from the arrow target

    NSComboButton.Style.split 里的分隔线,在视觉上把主操作目标和箭头目标分开

Prompt — paste into your agentPrompt —— 直接粘贴给你的代理

Use a Combo Button with NSComboButton (macOS 13+) in split style: clicking the main region performs the primary action, while the attached arrow region opens its NSMenu. Do not use a pop-up button, which displays a current selection, or a pull-down button, whose whole button opens an action menu.

使用组合按钮 NSComboButton(macOS 13+)的 split 样式:点主区域立即执行主操作,点附着的箭头区域打开它的 NSMenu。不要用弹出式按钮(pop-up button)——它显示的是当前选中项;也不要用下拉式按钮(pull-down button)——它整个按钮都用来打开操作菜单。

Debug prompt — when it misbehaves调试 Prompt —— 当它不听话时

Debug my macOS combo button (NSComboButton, macOS 13+). Rule out: unified vs split style confusion — in unified the whole button shows the menu, in split only the arrow section does; the menu property empty so the arrow does nothing; running on macOS 12 or earlier where NSComboButton does not exist and a popup-button fallback is needed. The symptom:

调试我的 macOS 组合按钮(NSComboButton,macOS 13+)。排除以下可能:unified 和 split 样式搞混——unified 下整个按钮都弹出菜单,split 下只有箭头区域弹菜单;menu 属性为空,箭头点了没反应;跑在 macOS 12 或更早版本上,NSComboButton 不存在,需要回退到弹出式按钮方案。症状是:

In code代码里叫什么

Framework框架Symbol符号Note说明
AppKit NSComboButton macOS 13+macOS 13+
AppKit NSComboButton.Style.split separate action and menu regions操作区域与菜单区域分离
SwiftUI Button + Menu no single native SwiftUI equivalent没有单一的原生 SwiftUI 等价物

See also相关词条