问题描述
我在NSCollectionViewItem
的视图上有一个NSTextField
.
当您单击NSCollectionViewItem
时,将选择该项目.
When you click an NSCollectionViewItem
the item is selected.
当您单击NSTextField
时,它会获得焦点,但是未选中文本字段后面的NSCollectionViewItem
.
When you click the NSTextField
it gains focus, but the NSCollectionViewItem
which is behind the text field does not get selected.
我想更改此最后一个行为,以便使文本字段获得焦点,并且还选择了查看项.
I want to change this last behaviour so the text field gets focus and the view item also gets selected.
做到这一点的最佳方法是什么?
What's the best way to do this?
推荐答案
我相信您必须继承NSTextField并重写mouseDown才能将事件传递给nextResponder(应将其设置为您的集合视图)
I believe you would have to subclass NSTextField and override mouseDown to pass the event to the nextResponder (which should be set to your collection view)
这篇关于NSTextField后面的NSCollectionViewItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!