检测哪个NstableView处于活动状态
我有一个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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于那些感兴趣的人,我发现最方便的解决方案是利用
nstableView
是nscontrol
的子类。因此,就像nsbutton一样,它可以在单击(鼠标上)时发送操作消息。对于每个表观,我将其“动作”连接到接口构建器中控制器对象的同一IBACTION选择器。
控制器识别发件人并采取相应的作用。
无需子类NstableView。
For those interested, the most convenient solution I found was to take advantage of the fact that
NSTableView
is a subclass ofNSControl
. 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.