don't use char hook to handle Esc in the dialogs, it is too blunt and prevents us from using it for the other purposes such as closing popup menus (bug 884713)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25649 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
014249a8f0
commit
16dd61ac10
@ -156,6 +156,7 @@ wxMSW:
|
||||
- accelerators are now initially hidden if appropriate (Peter Nielsen)
|
||||
- background colour of a wxComboBox may now be set
|
||||
- fixed wxListCtrl::GetItemText/BackgroundColour()
|
||||
- Esc can now be used to close menus in the dialogs (Hartmut Honisch)
|
||||
|
||||
wxGTK:
|
||||
|
||||
|
@ -113,8 +113,6 @@ BEGIN_EVENT_TABLE(wxDialog, wxDialogBase)
|
||||
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)
|
||||
@ -214,35 +212,6 @@ wxDialog::~wxDialog()
|
||||
Show(FALSE);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// kbd handling
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// By default, pressing escape cancels the dialog
|
||||
void wxDialog::OnCharHook(wxKeyEvent& event)
|
||||
{
|
||||
if (GetHWND())
|
||||
{
|
||||
// "Esc" works as an accelerator for the "Cancel" button, but it
|
||||
// shouldn't close the dialog which doesn't have any cancel button
|
||||
if ( (event.m_keyCode == WXK_ESCAPE) && FindWindow(wxID_CANCEL) )
|
||||
{
|
||||
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
||||
cancelEvent.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent(cancelEvent);
|
||||
|
||||
// ensure that there is another message for this window so the
|
||||
// ShowModal loop will exit and won't get stuck in GetMessage().
|
||||
::PostMessage(GetHwnd(), WM_NULL, 0, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// We didn't process this event.
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// showing the dialogs
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -1837,6 +1837,25 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
|
||||
bProcess = FALSE;
|
||||
break;
|
||||
|
||||
case VK_ESCAPE:
|
||||
{
|
||||
#if wxUSE_BUTTON
|
||||
wxButton *btn = wxDynamicCast(FindWindow(wxID_CANCEL),
|
||||
wxButton);
|
||||
if ( btn && btn->IsEnabled() )
|
||||
{
|
||||
// if we do have a cancel button, do press it
|
||||
btn->MSWCommand(BN_CLICKED, 0 /* unused */);
|
||||
|
||||
// we consumed the message
|
||||
return TRUE;
|
||||
}
|
||||
#endif // wxUSE_BUTTON
|
||||
|
||||
bProcess = FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_RETURN:
|
||||
{
|
||||
if ( (lDlgCode & DLGC_WANTMESSAGE) && !bCtrlDown )
|
||||
@ -1950,8 +1969,7 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
|
||||
}
|
||||
#endif // 1/0
|
||||
|
||||
// we handle VK_ESCAPE ourselves in wxDialog::OnCharHook() and we
|
||||
// shouldn't let IsDialogMessage() get it as it _always_ eats the
|
||||
// don't let IsDialogMessage() get VK_ESCAPE as it _always_ eats the
|
||||
// message even when there is no cancel button and when the message is
|
||||
// needed by the control itself: in particular, it prevents the tree in
|
||||
// place edit control from being closed with Escape in a dialog
|
||||
|
Loading…
Reference in New Issue
Block a user