NSTextField commitEditing 到绑定

发布于 2024-11-08 16:58:27 字数 488 浏览 0 评论 0原文

NSTextFieldtextShouldEndEditing 通常如何更新 coca 绑定(默认情况下)?我已经重写了该方法,并且作为副作用,绑定不再更新,因此我想恢复此行为。我看到的唯一建议是创建一个额外的 NSObjectController 和 commitEditing,但是原始的 textShouldEndEditing 使用了什么代码?

在我的情况下,我的 NSTextField 的值绑定到名为 JobsNSController。从我的 NSTextField 子类中,我看不到如何将 Jobs 引用到 commitEditingJobs 出现在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无边思念无边月 2024-11-15 16:58:27

我可以找到两个答案:

  1. infoForBinding。我不知道这个方法,它可以用来识别绑定控制器并定位它。

  2. 我原以为IBOutlet不能与我未在IB中初始化的子类一起使用,但我忘记了我可以从子类NSTextFields中删除的子类访问插座在我的应用程序中。然后很容易为我的 NSArrayController 创建一个 IBOutlet ,并且一切都按我希望的方式工作。

There were two answers for this that I could find:

  1. infoForBinding. I wasn't aware of this method and it can be used to identify the binding controller and target it.

  2. 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 subClassed NSTextFields in my application. It was then easy to create an IBOutlet to my NSArrayController and all worked as I hoped.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文