X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8e609c82594a57104ff5e0d4044b2e2697a4b576..7564225f8bff6e6c2ed27695836035fa85a81189:/src/mac/carbon/button.cpp?ds=sidebyside diff --git a/src/mac/carbon/button.cpp b/src/mac/carbon/button.cpp index c5a3f521bd..55785b73ac 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" @@ -102,13 +103,12 @@ bool wxButton::Create(wxWindow *parent, void wxButton::SetDefault() { - wxWindow *parent = GetParent(); + wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow); wxButton *btnOldDefault = NULL; - - if ( parent ) + if ( tlw ) { - btnOldDefault = wxDynamicCast(parent->GetDefaultItem(), wxButton); - parent->SetDefaultItem(this); + btnOldDefault = wxDynamicCast(tlw->GetDefaultItem(), wxButton); + tlw->SetDefaultItem(this); } if ( btnOldDefault )