]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/combobxc.cpp
cleanup
[wxWidgets.git] / src / mac / carbon / combobxc.cpp
index f5ba7c6f314e594e689913e0e4bf895c98d81319..dc03529a981e4af5b46ceb1fab8e8757cbc2a2f2 100644 (file)
 #include "wx/wxprec.h"
 
 #include "wx/combobox.h"
-#include "wx/button.h"
-#include "wx/menu.h"
+
+#ifndef WX_PRECOMP
+    #include "wx/button.h"
+    #include "wx/menu.h"
+#endif
+
 #include "wx/mac/uma.h"
 #if TARGET_API_MAC_OSX
 #ifndef __HIVIEW__
@@ -143,14 +147,10 @@ protected:
                 // This will invoke the dialog default action, such
                 // as the clicking the default button.
 
-                wxWindow *parent = GetParent();
-                while( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL ) {
-                    parent = parent->GetParent();
-                }
-                if ( parent && parent->GetDefaultItem() )
+                wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
+                if ( tlw && tlw->GetDefaultItem() )
                 {
-                    wxButton *def = wxDynamicCast(parent->GetDefaultItem(),
-                                                          wxButton);
+                    wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton);
                     if ( def && def->IsEnabled() )
                     {
                         wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );