]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/classic/listbox.cpp
updates from Adrián González Alba
[wxWidgets.git] / src / mac / classic / listbox.cpp
index 02f93f5c8d4de7e9105785073d5dc8e3b4383a23..d0de7211908e92d497b629330f176f01ea67a927 100644 (file)
 
 #if wxUSE_LISTBOX
 
 
 #if wxUSE_LISTBOX
 
-#include "wx/app.h"
 #include "wx/listbox.h"
 #include "wx/listbox.h"
-#include "wx/button.h"
-#include "wx/settings.h"
-#include "wx/toplevel.h"
-#include "wx/dynarray.h"
-#include "wx/log.h"
 
 
-#include "wx/utils.h"
+#ifndef WX_PRECOMP
+    #include "wx/dynarray.h"
+    #include "wx/log.h"
+    #include "wx/app.h"
+    #include "wx/utils.h"
+    #include "wx/button.h"
+    #include "wx/settings.h"
+    #include "wx/toplevel.h"
+#endif
 
 IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
 
 
 IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
 
@@ -922,14 +924,10 @@ void wxListBox::OnChar(wxKeyEvent& event)
 {
     if ( event.GetKeyCode() == WXK_RETURN || event.GetKeyCode() == WXK_NUMPAD_ENTER)
     {
 {
     if ( event.GetKeyCode() == WXK_RETURN || event.GetKeyCode() == WXK_NUMPAD_ENTER)
     {
-        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() );
             if ( def && def->IsEnabled() )
             {
                 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );