将选定的单选框绑定到 Cocoa 中的启用复选框
我以前没有经常使用 Cocoa 绑定,所以我在这里需要一些帮助。
我有一个单选按钮组( NSMatrix ),其中包含三个按钮和一个复选框。 我希望仅在选择最后一个单选按钮时启用该复选框。
网上找到了一个教程,建议将单选按钮组的选定标签属性绑定到复选框的启用属性。最后一个单选按钮的标签需要为 1,其他单选按钮的标签需要为 0。 这很好用。
问题是,如果选中复选框并更改单选按钮选择,尽管未启用,但它仍保持选中状态。我希望当该框更改为禁用状态时取消选中该框。
任何建议将不胜感激! 提前致谢!
有什么方法可以在不使用任何代码的情况下实现此目的吗?
I haven't worked with Cocoa bindings a lot before, so I would need a little help here.
I have a radio button group ( NSMatrix ) with three buttons and one checkbox.
I want the checkbox to be enabled only when the last radio button is selected.
Found a tutorial online which advised to bind the selected tag property of the radio button group to the enabled property of the checkbox. The last radiobutton needs to have a tag of 1, the others would need to have a tag of 0.
This works great.
The problem is, that if the checkbox is checked and the radiobutton selection is changed, it stays checked although it isn't enabled. I would want that the box gets unchecked when it changes to the disabled state.
Any advise would be appreciated!
Thanks in advance!
Any way to achieve this without any code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我怀疑没有代码是否可以做到这一点。
我使用 KVO 在模型中处理这个问题。代码看起来像这样:
在初始化期间:
I doubt it's possible to do this without code.
I handle this in the model, using KVO. Code looks something like this:
And during initialization: