检测哪个NstableView处于活动状态

发布于 2025-01-30 11:46:30 字数 457 浏览 5 评论 0原文

我有一个nssplitview,显示两个NstableView实例。我需要检测到哪个表视图已成为“活跃”(重点),这意味着用户单击的一个。我需要知道,因为每个表视图充当另一个视图的源列表,该视图显示了所选行的内容。这两个表都共享了这一视图。

我可以通过对nstableview进行亚分和对Mousedown的反应来做到这一点:或另一种方法,但我宁愿避免为此进行亚分。我也不想跟踪任何NSWINDOW事件,只是为了知道用户是否单击了其中一个表(我宁愿sub -Class nstableView)。

当前,我使用委托方法tableViewSelectionDidchange:,但是显然,此方法仅在选定的行更改时才调用。我需要知道,即使所选行没有更改,表也变得有效。

观察clickedrow表视图的属性似乎无法正常工作。如果可能不符合KVO。

有什么想法吗?

I have an NSSplitView showing two NSTableView instances. I need to detect which table view has become "active" (of focused), which means the one that the user has clicked. I need to know that because each table view acts as a source list for another view that shows the content of the selected row(s). This other view is shared for both tables.

I could do it by subclassing NSTableView and reacting to mouseDown: or another method but it I'd rather avoid subclassing just for that. I also don't want to track any NSWindow event just to know if the user has clicked one of the tables (I'd rather subclass NSTableView).

Currently, I use the delegate method tableViewSelectionDidChange:, but this method is, obviously, only called when the selected row changes. I need to know that a table becomes active even if the selected row hasn't changed.

Observing the clickedRow property of the table views doesn't appear to work. If may not be KVO compliant.

Any ideas?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

末骤雨初歇 2025-02-06 11:46:30

对于那些感兴趣的人,我发现最方便的解决方案是利用nstableViewnscontrol的子类。因此,就像nsbutton一样,它可以在单击(鼠标上)时发送操作消息。
对于每个表观,我将其“动作”连接到接口构建器中控制器对象的同一IBACTION选择器。
控制器识别发件人并采取相应的作用。
无需子类NstableView。

For those interested, the most convenient solution I found was to take advantage of the fact that NSTableView is a subclass of NSControl. So just like NSButton it can send action messages when clicked (upon mouse up).
For each tableView, I wired its "action" to the same ibaction selector of my controller object in interface builder.
The controller identifies the sender and acts accordingly.
No need to subclass NSTableView.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文