diff --git a/include/wx/osx/dvrenderers.h b/include/wx/osx/dvrenderers.h index e9ad8edd79..1c6b5b5687 100644 --- a/include/wx/osx/dvrenderers.h +++ b/include/wx/osx/dvrenderers.h @@ -207,6 +207,8 @@ public: unsigned col); private: + void DoInitButtonCell(int buttonType); + wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewToggleRenderer); }; diff --git a/src/osx/cocoa/dataview.mm b/src/osx/cocoa/dataview.mm index a95d29190e..de561b8b4e 100644 --- a/src/osx/cocoa/dataview.mm +++ b/src/osx/cocoa/dataview.mm @@ -3324,13 +3324,18 @@ wxDataViewToggleRenderer::wxDataViewToggleRenderer(const wxString& varianttype, wxDataViewCellMode mode, int align) : wxOSXDataViewDisabledInertRenderer(varianttype, mode, align) +{ + DoInitButtonCell(NSSwitchButton); +} + +void wxDataViewToggleRenderer::DoInitButtonCell(int buttonType) { NSButtonCell* cell; cell = [[NSButtonCell alloc] init]; - [cell setAlignment:ConvertToNativeHorizontalTextAlignment(align)]; - [cell setButtonType:NSSwitchButton]; + [cell setAlignment:ConvertToNativeHorizontalTextAlignment(GetAlignment())]; + [cell setButtonType: static_cast(buttonType)]; [cell setImagePosition:NSImageOnly]; SetNativeData(new wxDataViewRendererNativeData(cell)); [cell release]; @@ -3338,7 +3343,11 @@ wxDataViewToggleRenderer::wxDataViewToggleRenderer(const wxString& varianttype, void wxDataViewToggleRenderer::ShowAsRadio() { - [GetNativeData()->GetItemCell() setButtonType:NSRadioButton]; + // This is a bit wasteful, as we always create the cell using + // NSSwitchButton in the ctor and recreate it here, but modifying the + // existing cell doesn't seem to work well and delaying the creation of the + // cell until it's used doesn't seem to be worth it, so just recreate it. + DoInitButtonCell(NSRadioButton); } bool wxDataViewToggleRenderer::MacRender()