X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9d11268884fd82cfe72673566e403a40105ce703..d1526a6787a5dc39dd7c07662a355818527041e7:/src/mac/classic/textctrl.cpp diff --git a/src/mac/classic/textctrl.cpp b/src/mac/classic/textctrl.cpp index cae116ab43..076e53e031 100644 --- a/src/mac/classic/textctrl.cpp +++ b/src/mac/classic/textctrl.cpp @@ -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() );