STextField后面的NSCollectionViewIte

STextField后面的NSCollectionViewIte

本文介绍了NSTextField后面的NSCollectionViewItem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 20:43