From cec464a99841d8a7aa31bce640048fdcbe47301a Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sat, 22 Aug 2015 16:09:21 -0400 Subject: [PATCH] Fixed the uiRadioButtons buttons not showing up. --- redo/reredo/darwin/radiobuttons.m | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/redo/reredo/darwin/radiobuttons.m b/redo/reredo/darwin/radiobuttons.m index 8f879f36..2db320d4 100644 --- a/redo/reredo/darwin/radiobuttons.m +++ b/redo/reredo/darwin/radiobuttons.m @@ -28,11 +28,22 @@ void uiRadioButtonsAppend(uiRadioButtons *r, const char *text) uiRadioButtons *uiNewRadioButtons(void) { uiRadioButtons *r; + NSButtonCell *cell; r = (uiRadioButtons *) uiNewControl(uiRadioButtonsType()); - r->matrix = [[NSMatrix alloc] initWithFrame:NSZeroRect]; - [r->matrix setMode:NSRadioModeMatrix]; + // we have to set up the NSMatrix this way (prototype first) + // otherwise we won't be able to change its properties (such as the button type) + cell = [NSButtonCell new]; + [cell setButtonType:NSRadioButton]; + // works on NSCells too (same selector) + uiDarwinSetControlFont((NSControl *) cell, NSRegularControlSize); + + r->matrix = [[NSMatrix alloc] initWithFrame:NSZeroRect + mode:NSRadioModeMatrix + prototype:cell + numberOfRows:0 + numberOfColumns:0]; // TODO should we allow an initial state of no selection, but not allow the user to select nothing? [r->matrix setAllowsEmptySelection:NO]; [r->matrix setIntercellSpacing:NSMakeSize(4, 2)]; @@ -40,9 +51,6 @@ uiRadioButtons *uiNewRadioButtons(void) [r->matrix setDrawsBackground:NO]; [r->matrix setDrawsCellBackground:NO]; [r->matrix setAutosizesCells:YES]; - [[r->matrix prototype] setButtonType:NSRadioButton]; - // works on NSCells too (same selector) - uiDarwinSetControlFont((NSControl *) [r->matrix prototype], NSRegularControlSize); uiDarwinFinishNewControl(r, uiRadioButtons);