X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/de6185e212ebc37ff11ff70278e3c4f68419b097..3f4a2351e4c677c88c18ea812b609477adee7380:/src/mac/classic/listbox.cpp diff --git a/src/mac/classic/listbox.cpp b/src/mac/classic/listbox.cpp index 303848e70c..d0de721190 100644 --- a/src/mac/classic/listbox.cpp +++ b/src/mac/classic/listbox.cpp @@ -20,12 +20,11 @@ #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 -#include "wx/button.h" -#include "wx/settings.h" -#include "wx/toplevel.h" - IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl) BEGIN_EVENT_TABLE(wxListBox, wxControl) @@ -925,14 +924,10 @@ void wxListBox::OnChar(wxKeyEvent& event) { 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() );