]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/app.cpp
updates from Adrián González Alba
[wxWidgets.git] / src / mac / carbon / app.cpp
index 97ba0f25e5fa4922811da6d802f7cf121c93a11f..154369334d552aa03a7661534254c59dcbbfaae1 100644 (file)
@@ -31,9 +31,9 @@
     #include "wx/msgdlg.h"
     #include "wx/textctrl.h"
     #include "wx/memory.h"
+    #include "wx/gdicmn.h"
 #endif
 
-#include "wx/gdicmn.h"
 #include "wx/module.h"
 #include "wx/tooltip.h"
 #include "wx/docview.h"
@@ -1576,14 +1576,18 @@ bool wxApp::MacSendCharEvent( wxWindow* focus , long keymessage , long modifiers
         {
             if ( keyval == WXK_RETURN )
             {
-                wxButton *def = wxDynamicCast(focus->GetDefaultItem(), wxButton);
-                if ( def && def->IsEnabled() )
+                wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(focus), wxTopLevelWindow);
+                if ( tlw && tlw->GetDefaultItem() )
                 {
-                    wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
-                    event.SetEventObject(def);
-                    def->Command(event);
+                    wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton);
+                    if ( def && def->IsEnabled() )
+                    {
+                        wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
+                        event.SetEventObject(def);
+                        def->Command(event);
 
-                    return true ;
+                        return true ;
+                    }
                 }
             }
             else if (keyval == WXK_ESCAPE || (keyval == '.' && modifiers & cmdKey ) )