Outline View 大纲视图 macos

Library

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

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

  1. 1 Disclosure triangle披露三角 NSOutlineView

    “The little expand arrow beside a row” is its disclosure triangle.

    「行旁边那个展开小箭头」就是披露三角。

    Prompt fragmentPrompt 片段

    the native disclosure triangle supplied by NSOutlineView for a row with children

    NSOutlineView 为有子级的行提供的原生披露三角

  2. 2 Indentation level缩进层级 NSOutlineView.level(forItem:)

    “How far a child row steps in from its parent” is its indentation level.

    「子行相对父行往里缩多少」就是它的缩进层级。

    Prompt fragmentPrompt 片段

    the NSOutlineView.level(forItem:) indentation that makes each child depth visible

    NSOutlineView.level(forItem:) 的缩进,让每一层子级深度都看得见

  3. 3 Row selection highlight行选中高亮 NSTableRowView.isSelected

    “The colored strip behind the current row” is the row selection highlight.

    「当前行背后的彩色条」就是行选中高亮。

    Prompt fragmentPrompt 片段

    the NSTableRowView.isSelected highlight spanning the selected outline row

    NSTableRowView.isSelected 的高亮,铺满选中的大纲行

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

Use an Outline View with NSOutlineView (SwiftUI: OutlineGroup) for the indented hierarchy: parent rows receive disclosure triangles and expanding one reveals child rows directly beneath it. Use a flat list only when rows have no children; apply source-list styling separately if the outline serves as a sidebar.

用大纲视图 NSOutlineView(SwiftUI:OutlineGroup)实现缩进层级:父行带披露三角,展开后子行直接出现在它下方。只有当行没有子级时才用扁平列表;如果大纲用作边栏,再单独套源列表(source list)样式。

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

Debug my macOS outline view (NSOutlineView). Rule out: rows refusing to expand because isItemExpandable and the child-count delegate answers disagree; reloadItem without reloadChildren:true leaving stale children; autosaveExpandedItems silently broken because items lack stable identity for persistentObject round-trips; row animations jumping because the model mutated before the animated update ran. The symptom:

调试我的 macOS 大纲视图(NSOutlineView)。排除以下可能:isItemExpandable 和子项数量的 delegate 回答不一致,行拒绝展开;reloadItem 没带 reloadChildren:true,子项还是旧的;autosaveExpandedItems 悄悄失效,因为 item 缺乏稳定标识,persistentObject 存取对不上;模型在动画更新之前就变了,行动画乱跳。症状是:

In code代码里叫什么

Framework框架Symbol符号Note说明
AppKit NSOutlineView
SwiftUI OutlineGroup
SwiftUI List when supplied hierarchical children在提供层级 children 数据时

See also相关词条