From: Vadim Zeitlin Date: Sun, 24 Jul 2011 10:50:51 +0000 (+0000) Subject: Ignore WM_CLOSE generated by wxMSW edit control when Escape is pressed. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/d19d14c5505b969967103093ec2f8e600793f218 Ignore WM_CLOSE generated by wxMSW edit control when Escape is pressed. 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 --- diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 582e3a1bd1..3cf85ba094 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -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(); }