开发者

Setting the value of a Radio button on a NSButtonCell

I have a NSButtonCell set to style Radio with 1 row and 2 columns. It basically serves as a 开发者_运维知识库way to select from one option or the other.

How can I set the value to one or the other (but not both)?

I tried playing with:

[_ButtonCellSet setState:0];

But that's not the solution.

This is done on XCode 4.

Thanks for the help.


The way I would do this is to put the radio buttons in an NSMatrix and use selectCellAtRow:column: to change the selection. This code will toggle the selection back and forth between two radio buttons in a 1x2 matrix:

-(IBAction)click:(id)sender {
    cursel = 1 - cursel;
    [radioGroup selectCellAtRow:0 column:cursel];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜