user2656381
user2656381

Reputation: 145

How to deselect radio button in cocoa

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

Upvotes: 1

Views: 1266

Answers (1)

Bob Vork
Bob Vork

Reputation: 2947

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

[prototype setState:NSOffState]

Upvotes: 2

Related Questions