From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Wed, 3 Oct 2012 08:32:49 +0000 (+0000)
Subject: Do use IsEscapeKey() in wxDialog escape key handling.
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f821bc36178aded12912e8638ba0c6e3c018d1bf

Do use IsEscapeKey() in wxDialog escape key handling.

This method was added back in r40686 but was never actually used anywhere. Do
use it in wxDialogBase::OnCharHook() now instead of hard-coding the check for
WXK_ESCAPE, this should allow using Cmd+. to work like Escape under Mac which
was apparently the intention of the code in src/osx/dialog_osx.cpp.

Also fix IsEscapeKey() itself to ignore any modifiers as at least under MSW
Esc always closes the dialog, even if Shift or Alt is pressed.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72610 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---

diff --git a/src/common/dlgcmn.cpp b/src/common/dlgcmn.cpp
index d95dafd786..5cbbc7e390 100644
--- a/src/common/dlgcmn.cpp
+++ b/src/common/dlgcmn.cpp
@@ -461,14 +461,16 @@ bool wxDialogBase::SendCloseButtonClickEvent()
 
 bool wxDialogBase::IsEscapeKey(const wxKeyEvent& event)
 {
-    // for most platforms, Esc key is used to close the dialogs
-    return event.GetKeyCode() == WXK_ESCAPE &&
-                event.GetModifiers() == wxMOD_NONE;
+    // For most platforms, Esc key is used to close the dialogs.
+    //
+    // Notice that we intentionally don't check for modifiers here, Shift-Esc,
+    // Alt-Esc and so on still close the dialog, typically.
+    return event.GetKeyCode() == WXK_ESCAPE;
 }
 
 void wxDialogBase::OnCharHook(wxKeyEvent& event)
 {
-    if ( event.GetKeyCode() == WXK_ESCAPE )
+    if ( IsEscapeKey(event) )
     {
         if ( SendCloseButtonClickEvent() )
         {