简体   繁体   English

NSOutlineView 中的 NSTextField 不发送其操作

[英]NSTextField in an NSOutlineView doesn't send its action

I have a view-based NSOutlineView that I use as a sidebar.我有一个基于视图的NSOutlineView用作侧边栏。

I load each sidebar widget by instantiating a view controller from a storyboard, then setting the cell's view to that of the view controller.我通过从 storyboard 实例化视图 controller 来加载每个侧边栏小部件,然后将单元格的视图设置为视图 controller 的视图。

At first I couldn't even focus the text field, but found out I had to subclass the outline view and return true for validateProposedFirstResponder起初我什至无法关注文本字段,但发现我必须对大纲视图进行子类化并为validateProposedFirstResponder返回 true

I can't get any action out of the text field.我无法从文本字段中获得任何操作。 Here's what I tried这是我尝试过的

  • IBAction. IBA 动作。 Never called.从来没有打电话。
  • Setting the view controller as the delegate for the text field.将视图 controller 设置为文本字段的代表。 Never called.从来没有打电话。
  • Setting the text view's outlet's action and target directly (target = self, action = a selector to and objc function).直接设置文本视图的出口的actiontarget (目标 = self,动作 = 选择器和 objc 函数)。 Never called.从来没有打电话。

I suspect it's the Outline view that is blocking my "text editing finished" action?我怀疑是大纲视图阻止了我的“文本编辑完成”操作? How can I make my text field tell the View Controller that it has been edited?如何让我的文本字段告诉 View Controller 它已被编辑?

I am able to read the value of the text field through its IBOutlet, so the connection works.我能够通过其 IBOutlet 读取文本字段的值,因此连接正常。

I also noted that upon hitting Enter in the text field, it immediately loses focus.我还注意到,在文本字段中按 Enter 后,它会立即失去焦点。 This was not the behavior outside the outline view.这不是大纲视图之外的行为。

I had to add the instantiated view controller to the presenting view controller.我必须将实例化视图 controller 添加到呈现视图 controller。 Just presenting the instantiated view controller's view in the outline view was not enough.仅在大纲视图中呈现实例化视图控制器的视图是不够的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM