From c84d0c864a244e99d519206a00d9fdcdd37f3670 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 7 May 2009 17:09:21 +0000 Subject: [PATCH] generate the click event from the button with correct id if SetEscapeId() was called instead of always using wxID_CANCEL (closes #10746) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60547 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/dlgcmn.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/dlgcmn.cpp b/src/common/dlgcmn.cpp index aa25908a2b..eb33b068ee 100644 --- a/src/common/dlgcmn.cpp +++ b/src/common/dlgcmn.cpp @@ -450,6 +450,12 @@ void wxDialogBase::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) // destroy the dialog. The default OnCancel (above) simply ends a modal // dialog, and hides a modeless dialog. + int idCancel = GetEscapeId(); + if ( idCancel == wxID_NONE ) + return; + if ( idCancel == wxID_ANY ) + idCancel = wxID_CANCEL; + // VZ: this is horrible and MT-unsafe. Can't we reuse some of these global // lists here? don't dare to change it now, but should be done later! static wxList closing; @@ -459,7 +465,7 @@ void wxDialogBase::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) closing.Append(this); - wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); + wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, idCancel); cancelEvent.SetEventObject( this ); GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog -- 2.47.2