centralized Esc key handling for closing the dialogs in wxDialogBase:

1. added wxDialogBase::OnCharHook() and removed this event handler from
   all the other ports
2. also removed ad hoc code doing the same thing in wxMSW (MSWProcessMessage()
   override in wxDialog) and wxGTK (in gtk_window_key_press_callback())
3. reimplemented EmulateButtonClickIfPresent() portably and also moved it
   to wxDialogBase from wxMSW wxDialog


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40686 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-08-19 22:36:10 +00:00
parent 8f4931874c
commit 0be2741893
12 changed files with 82 additions and 169 deletions

View File

@@ -39,7 +39,6 @@ BEGIN_EVENT_TABLE(wxDialog, wxDialogBase)
EVT_BUTTON(wxID_OK, wxDialog::OnOK)
EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
EVT_CHAR_HOOK(wxDialog::OnCharHook)
EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
EVT_CLOSE(wxDialog::OnCloseWindow)
@@ -163,40 +162,6 @@ wxDialog::~wxDialog()
Show(false);
} // end of wxDialog::~wxDialog
//
// By default, pressing escape cancels the dialog
//
void wxDialog::OnCharHook(
wxKeyEvent& rEvent
)
{
if (GetHWND())
{
if (rEvent.m_keyCode == WXK_ESCAPE)
{
//
// Behaviour changed in 2.0: we'll send a Cancel message
// to the dialog instead of Close.
//
wxCommandEvent vCancelEvent( wxEVT_COMMAND_BUTTON_CLICKED
,wxID_CANCEL
);
vCancelEvent.SetEventObject( this );
GetEventHandler()->ProcessEvent(vCancelEvent);
//
// Ensure that there is another message for this window so the
// ShowModal loop will exit and won't get stuck in GetMessage().
//
::WinPostMsg(GetHwnd(), WM_NULL, 0, 0);
return;
}
}
// We didn't process this event.
rEvent.Skip();
}
// ----------------------------------------------------------------------------
// showing the dialogs
// ----------------------------------------------------------------------------