如何在Mac OS X上创建“源列表”?

时间:2021-02-17 22:21:37

The Apple guidelines talk about using a source list - how do I create this source list, either in Carbon or Cocoa? Is there an official API somewhere for this component?

Apple指南谈到使用源列表 - 如何在Carbon或Cocoa中创建此源列表?这个组件的某个地方是否有官方API?

1 个解决方案

#1


A source list in Cocoa is just an NSOutlineView configured in a particular way. You can drag one out in Interface Builder and set the highlight mode to Source List. You'll probably also want to turn off the header row, change it to a single column, and change the visible scrollbars on the enclosing NSScrollView.

Cocoa中的源列表只是以特定方式配置的NSOutlineView。您可以在Interface Builder中拖出一个并将突出显示模式设置为Source List。您可能还想关闭标题行,将其更改为单个列,并更改封闭的NSScrollView上的可见滚动条。

You'll also need to implement the delegate method to determine which rows should be the "Group Rows":

您还需要实现委托方法以确定哪些行应为“组行”:

- (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item

Apple provided sample code http://developer.apple.com/samplecode/SourceView demonstrates how to build a fully featured source list.

Apple提供了示例代码http://developer.apple.com/samplecode/SourceView演示了如何构建功能齐全的源列表。

#1


A source list in Cocoa is just an NSOutlineView configured in a particular way. You can drag one out in Interface Builder and set the highlight mode to Source List. You'll probably also want to turn off the header row, change it to a single column, and change the visible scrollbars on the enclosing NSScrollView.

Cocoa中的源列表只是以特定方式配置的NSOutlineView。您可以在Interface Builder中拖出一个并将突出显示模式设置为Source List。您可能还想关闭标题行,将其更改为单个列,并更改封闭的NSScrollView上的可见滚动条。

You'll also need to implement the delegate method to determine which rows should be the "Group Rows":

您还需要实现委托方法以确定哪些行应为“组行”:

- (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item

Apple provided sample code http://developer.apple.com/samplecode/SourceView demonstrates how to build a fully featured source list.

Apple提供了示例代码http://developer.apple.com/samplecode/SourceView演示了如何构建功能齐全的源列表。