NSTextField commitEditing 到绑定
NSTextField
的 textShouldEndEditing
通常如何更新 coca 绑定(默认情况下)?我已经重写了该方法,并且作为副作用,绑定不再更新,因此我想恢复此行为。我看到的唯一建议是创建一个额外的 NSObjectController 和 commitEditing,但是原始的 textShouldEndEditing 使用了什么代码?
在我的情况下,我的 NSTextField
的值绑定到名为 Jobs 的 NSController
。从我的 NSTextField
子类中,我看不到如何将 Jobs 引用到 commitEditing
。 Jobs 出现在 Interface Builder 中,是为 Jobs 实体创建 NSArrayController
的结果。
How does textShouldEndEditing
for an NSTextField
usually update coca bindings (by default)? I've overridden the method and, as a side-effect, bindings are no longer updating so I want to reinstate this behavior. The only advice I've seen is to create an additional NSObjectController
and commitEditing
to that but what code did the original textShouldEndEditing
use?
In my situation, my NSTextField
has its value bound to an NSController
called Jobs. From my NSTextField
subclass, I can see no way to reference Jobs to commitEditing
. Jobs is present in Interface Builder as a result of creating an NSArrayController
for a Jobs entity.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可以找到两个答案:
infoForBinding
。我不知道这个方法,它可以用来识别绑定控制器并定位它。我原以为
IBOutlet
不能与我未在IB中初始化的子类一起使用,但我忘记了我可以从子类NSTextFields
中删除的子类访问插座在我的应用程序中。然后很容易为我的NSArrayController
创建一个IBOutlet
,并且一切都按我希望的方式工作。There were two answers for this that I could find:
infoForBinding
. I wasn't aware of this method and it can be used to identify the binding controller and target it.I had thought an
IBOutlet
couldn't be used with subClasses I wasn't initialising in IB but I forgot I could access the outlet from the dropped in subClassedNSTextFields
in my application. It was then easy to create anIBOutlet
to myNSArrayController
and all worked as I hoped.