NSTableView 中的不同单元格以及绑定

发布于 2024-08-26 12:49:55 字数 599 浏览 2 评论 0原文

我正在处理 nstableview,其中包含动态创建的一些属性的信息。每行包含一些常见的单元格(例如名称),但在一列中它们具有不同的单元格。一些属性将具有 NSSliderCell、其他 NSButtonCell 等。所有这些都绑定到 NSDictionaryController。我已经掌握了使用 nsslidercell 和 nsbuttoncell 的基础知识,在我的委托中使用 -(NSCell *) tableView:(NSTableView *)tableView dataCellForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row ,并为每行返回不同的单元格。 nstablecolumn 具有从属性值(通常是 nsnumber)到列值的绑定。

这一切都有效,但现在我想将 NSSegmentedCell 添加到新的属性类型,并且我遇到了问题,因为我现在需要将属性的值绑定到列的 selectedIndex,而不是值。但我怎样才能在不破坏其他属性的情况下做到这一点呢?

我还尝试对 NSSegmentedCell 进行子类化,并让 objectValue 控制它的 selectedIndex,但它不起作用......

有什么想法如何做到这一点?

im working on a nstableview that contains information for some properties that are dynamicly created. Each row contains some cells that are common (name for example), but in one column they have different cells. Some properties will have NSSliderCell, other NSButtonCell etc. All of this is binded up to a NSDictionaryController. I've got the basics to work with nsslidercell and nsbuttoncell using -(NSCell *) tableView:(NSTableView *)tableView dataCellForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row in my delegate, and returning different cells for each row. And the nstablecolumn has a binding from the property's value (usually a nsnumber) to the value of the column.

This all works, but now i wanted to add a NSSegmentedCell to a new property type, and i experienced problems, because i now needed to bind the value of the property to the selectedIndex of the column, and not the value. But how can i do this without breaking the other properties?

I've also tried to subclass NSSegmentedCell, and make objectValue controlling the selectedIndex of it, but it didn't work...

Any ideas how to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文