如何正确设置启用 NSSegmentedControl
我希望我的 NSSegmentedControl
在启用时选择一个分段,在禁用时不选择任何分段(iTunes 中的视图 NSSegmentedControl 具有的行为类型)。
这里有一些图片:
启用并选择
正确禁用
禁用但不正确
(*)我认识到我可以编写一个函数,每当 BOOL 属性更改时调用,在这个函数中,我可以设置所有被分割的段或选择适当的段,但我想知道是否有一种方法通过 Cocoa Bindings 或 Interface Builder 来完成此操作。
更新:添加了一些问题的图像
I'd like to have my NSSegmentedControl
with a segment selected when enabled and with no segment selected while disabled (the kind of behavior that the view NSSegmentedControl in iTunes has).
Here some images:
enabled and selected
disabled correctly
disabled but not correctly
(*) I recognize that I could write a function to call whenever the BOOL property changes and in this function I could set all the segments desected or select the appropriate one, BUT I'd like to know if there's a way to accomplish this through Cocoa Bindings or Interface Builder.
UPDATE: added some images of the problem
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
编辑:我对此并不完全确定,但我认为“无选择占位符”是您最好的选择。 http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/CocoaBindingsRef/Concepts/BindingsOptions.html%23//apple_ref/doc/uid/20002304-187525
我仍然认为当您有条件地禁用该控件时,您必须以编程方式指定不进行任何选择。
EDIT: I am not completely sure about this, but i think 'No Selection Placeholder' is your best bet. http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/CocoaBindingsRef/Concepts/BindingsOptions.html%23//apple_ref/doc/uid/20002304-187525
I still think you would have to programmatically specify no selection when you conditionally disable the control though.
编程解决方案可以是这样的:
我只是为与
viewSegment
绑定的 BOOL 属性segmentEnabled
实现自己的设置器The programmatic solution can be something like this:
I'm just implementing my own setter for the BOOL property
segmentEnabled
which is being binded with theviewSegment