#if wxUSE_BUTTON
#include "wx/button.h"
+
+#ifndef WX_PRECOMP
+ #include "wx/toplevel.h"
+#endif
+
#include "wx/stockitem.h"
#include "wx/gtk1/private.h"
void wxButton::SetDefault()
{
- wxWindow *parent = GetParent();
- wxCHECK_RET( parent, _T("button without parent?") );
+ wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
+ wxCHECK_RET( tlw, _T("button without top level window?") );
- parent->SetDefaultItem(this);
+ tlw->SetDefaultItem(this);
GTK_WIDGET_SET_FLAGS( m_widget, GTK_CAN_DEFAULT );
gtk_widget_grab_default( m_widget );