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
This commit is contained in:
Vadim Zeitlin
2009-05-07 17:09:21 +00:00
parent 5a58a1342d
commit c84d0c864a

View File

@@ -450,6 +450,12 @@ void wxDialogBase::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
// destroy the dialog. The default OnCancel (above) simply ends a modal // destroy the dialog. The default OnCancel (above) simply ends a modal
// dialog, and hides a modeless dialog. // 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 // 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! // lists here? don't dare to change it now, but should be done later!
static wxList closing; static wxList closing;
@@ -459,7 +465,7 @@ void wxDialogBase::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
closing.Append(this); closing.Append(this);
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, idCancel);
cancelEvent.SetEventObject( this ); cancelEvent.SetEventObject( this );
GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog