From 4455332266b332ca005c3430234f9a2b372b5764 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/trunk@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 656a835b6e..87757f78e2 100644 --- a/src/mac/carbon/listbox.cpp +++ b/src/mac/carbon/listbox.cpp @@ -925,10 +925,14 @@ void wxListBox::OnChar(wxKeyEvent& event) /* generate wxID_CANCEL if command-. or has been pressed (typically in dialogs) */ else if (event.GetKeyCode() == WXK_ESCAPE || (event.GetKeyCode() == '.' && event.MetaDown() ) ) { + // FIXME: look in ancestors, not just parent. wxWindow* win = GetParent()->FindWindow( wxID_CANCEL ) ; - wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL); - new_event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( new_event ); + if (win) + { + wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL); + new_event.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent( new_event ); + } } else if ( event.GetKeyCode() == WXK_TAB ) { diff --git a/src/mac/listbox.cpp b/src/mac/listbox.cpp index 656a835b6e..87757f78e2 100644 --- a/src/mac/listbox.cpp +++ b/src/mac/listbox.cpp @@ -925,10 +925,14 @@ void wxListBox::OnChar(wxKeyEvent& event) /* generate wxID_CANCEL if command-. or has been pressed (typically in dialogs) */ else if (event.GetKeyCode() == WXK_ESCAPE || (event.GetKeyCode() == '.' && event.MetaDown() ) ) { + // FIXME: look in ancestors, not just parent. wxWindow* win = GetParent()->FindWindow( wxID_CANCEL ) ; - wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL); - new_event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( new_event ); + if (win) + { + wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL); + new_event.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent( new_event ); + } } else if ( event.GetKeyCode() == WXK_TAB ) { -- 2.45.2