How to deselect radio button in cocoa

1.2k views Asked by At

I'm a newbie. I have a problem with NSMatrix. I created mutiple NSMatrix but i want first loading, they not checked. I used this code to created them but it always checked.

 prototype= [[NSButtonCell alloc] init];
    [prototype setTitle:@""];
    [prototype setButtonType:NSRadioButton];
    NSRect matrixRect = NSMakeRect(400, textfield_Y, 50, 20);
    myMatrix = [[NSMatrix alloc] initWithFrame:matrixRect
                                          mode:NSRadioModeMatrix
                                     prototype:(NSCell *)prototype
                                  numberOfRows:1
                               numberOfColumns:1];
    [myMatrix setTag:300+i];
    //[myMatrix setAction:@selector(radioButtonClicked:)];
    [myMatrix setTarget:self];
    NSArray *cellArray = [myMatrix cells];
    [[cellArray objectAtIndex:0] setTag:0];
    [guiView addSubview:myMatrix];
    [prototype release];
    [myMatrix release];

Any ideas? Thanks a lot

1

There are 1 answers

1
Bob Vork On

On an NSButtonCell you would use the setState method of NSCell:

[prototype setState:NSOffState]