From fad7abc046ae879625380419e79ded5c8a12e123 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sun, 13 Apr 2003 22:56:09 +0000 Subject: [PATCH] Test for result of searching for wxID_CANCEL button git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@20207 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/listbox.cpp | 10 +++++++--- src/mac/listbox.cpp | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/mac/carbon/listbox.cpp b/src/mac/carbon/listbox.cpp index 120a417fbf..f777194619 100644 --- a/src/mac/carbon/listbox.cpp +++ b/src/mac/carbon/listbox.cpp @@ -965,9 +965,13 @@ void wxListBox::OnChar(wxKeyEvent& event) else if (event.KeyCode() == WXK_ESCAPE || (event.KeyCode() == '.' && event.MetaDown() ) ) { wxWindow* win = GetParent()->FindWindow( wxID_CANCEL ) ; - wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL); - new_event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( new_event ); + // FIXME: try ancestor, not just parent + if (win) + { + wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL); + new_event.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent( new_event ); + } } else if ( event.KeyCode() == WXK_TAB ) { diff --git a/src/mac/listbox.cpp b/src/mac/listbox.cpp index 120a417fbf..f777194619 100644 --- a/src/mac/listbox.cpp +++ b/src/mac/listbox.cpp @@ -965,9 +965,13 @@ void wxListBox::OnChar(wxKeyEvent& event) else if (event.KeyCode() == WXK_ESCAPE || (event.KeyCode() == '.' && event.MetaDown() ) ) { wxWindow* win = GetParent()->FindWindow( wxID_CANCEL ) ; - wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL); - new_event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( new_event ); + // FIXME: try ancestor, not just parent + if (win) + { + wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL); + new_event.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent( new_event ); + } } else if ( event.KeyCode() == WXK_TAB ) {