X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6c20e8f816b21b911e3a8ed8197c21df6ce726d6..9154a136d5e1d79a4be2cf012e4a815fdc6df3ff:/src/mac/carbon/button.cpp diff --git a/src/mac/carbon/button.cpp b/src/mac/carbon/button.cpp index b1d1f7228f..fe3f479870 100644 --- a/src/mac/carbon/button.cpp +++ b/src/mac/carbon/button.cpp @@ -15,6 +15,7 @@ #ifndef WX_PRECOMP #include "wx/panel.h" + #include "wx/toplevel.h" #endif #include "wx/stockitem.h" @@ -100,20 +101,19 @@ bool wxButton::Create(wxWindow *parent, return true; } -void wxButton::SetDefault() +wxWindow *wxButton::SetDefault() { - wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow); - wxButton *btnOldDefault = NULL; - if ( tlw ) - { - btnOldDefault = wxDynamicCast(tlw->GetDefaultItem(), wxButton); - tlw->SetDefaultItem(this); - } + wxWindow *btnOldDefault = wxButtonBase::SetDefault(); if ( btnOldDefault ) - btnOldDefault->m_peer->SetData(kControlButtonPart , kControlPushButtonDefaultTag , (Boolean) 0 ) ; + { + // cast needed to access the protected member + btnOldDefault->GetPeer()->SetData(kControlButtonPart , kControlPushButtonDefaultTag , (Boolean) 0 ) ; + } m_peer->SetData(kControlButtonPart , kControlPushButtonDefaultTag , (Boolean) 1 ) ; + + return btnOldDefault; } wxSize wxButton::DoGetBestSize() const