]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/classic/textctrl.cpp
wxGetOsVersion() compilation andl inking fixes for wxMac
[wxWidgets.git] / src / mac / classic / textctrl.cpp
index cae116ab4337e9d2dcf32ea6ef8013326cebe758..076e53e031cf4e9936789c72f4a71ffc99bd6e65 100644 (file)
@@ -1622,14 +1622,10 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
             }
             if ( !(m_windowStyle & wxTE_MULTILINE) )
             {
-                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() );