]> git.saurik.com Git - wxWidgets.git/commitdiff
Ignore WM_CLOSE generated by wxMSW edit control when Escape is pressed.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 24 Jul 2011 10:50:51 +0000 (10:50 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 24 Jul 2011 10:50:51 +0000 (10:50 +0000)
Multiline edit control posts WM_CLOSE to its parent window when Escape key is
pressed inside it for some reason. This is unwanted as it totally bypasses our
logic for only closing the dialog when Escape is pressed if there is a
Cancel-like button in it, so suppress this behaviour by not letting the edit
control to get Escape at all.

Closes #12501.

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

src/msw/textctrl.cpp

index 582e3a1bd15fab07d3fadd35351e359bea15c05e..3cf85ba094ab52ad3268bf2541d33f2ca97d2979 100644 (file)
@@ -1810,6 +1810,14 @@ void wxTextCtrl::OnKeyDown(wxKeyEvent& event)
         }
     }
 
+    // Default window procedure of multiline edit controls posts WM_CLOSE to
+    // the parent window when it gets Escape key press for some reason, prevent
+    // it from doing this as this resulted in dialog boxes being closed on
+    // Escape even when they shouldn't be (we do handle Escape ourselves
+    // correctly in the situations when it should close them).
+    if ( event.GetKeyCode() == WXK_ESCAPE && IsMultiLine() )
+        return;
+
     // no, we didn't process it
     event.Skip();
 }