beardedN5rd
beardedN5rd

Reputation: 185

Sizing ButtonCells in NSMatrix

I am trying to implement a Radiogroup with cocoa and used the example provided by apple Using Radio Buttons

The following screenshot shows the problem I have. Even if the NSMatrix containing the cells have a NSRect large enough the cells themselves are not wide enough to display the titles.

How can I correct this?

enter image description here


NSButtonCell *prototype = [[[NSButtonCell alloc] init]autorelease];
[prototype setButtonType:NSRadioButton];

[prototype setBordered:YES];//only for testing

_view = [[[NSMatrix alloc] initWithFrame:rect
                                    mode:NSRadioModeMatrix
                               prototype:(NSCell *)prototype
                            numberOfRows:3
                         numberOfColumns:1]autorelease];

NSArray *cellArray = [_view cells];
for (std::size_t index = 0; index < 3; ++index)
{
    [[cellArray objectAtIndex:index] setTitle:@"a title"];
}

Upvotes: 1

Views: 45

Answers (1)

Girish Kolari
Girish Kolari

Reputation: 2515

Use setCellSize of matrix.

NSSize size = [_view cellSize];
size.width = 400;
[_view setCellSize:size];

Upvotes: 1

Related Questions