From c43b59616f3a78d489c167c8ddd05576f7b0879b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20G=C3=B6pfert?= Date: Mon, 20 Jun 2016 10:40:36 +0200 Subject: [PATCH] Make Ctrl+A not work in multiline wxTextCtrl in MSW The native EDIT control doesn't handle this key combination, but RICHEDIT does and people just expect it to work, so handle it at wxMSW level. Closes https://github.com/wxWidgets/wxWidgets/pull/300 --- docs/changes.txt | 1 + src/msw/textctrl.cpp | 27 ++++++++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index a0485c3f6b..bc8d33f0fa 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -150,6 +150,7 @@ wxMSW: methods return wxAccStatus::wxACC_NOT_SUPPORTED. - Return null BSTR from wxIAccessible if string returned from wxAccesible method is empty. +- Handle Ctrl-A in non-rich multiline text controls (Jens Göpfert). wxOSX: diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 696103e738..294ecc8232 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -2054,13 +2054,26 @@ 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; + if ( IsMultiLine() ) + { + // 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 ) + return; + + // We also handle Ctrl-A as the native EDIT control doesn't do it by + // default (but RICHEDIT one does, so there is no need to check for it + // in the switch above), however it's a de facto standard accelerator + // and people expect it to work. + if ( event.GetModifiers() == wxMOD_CONTROL && event.GetKeyCode() == 'A' ) + { + SelectAll(); + return; + } + } // no, we didn't process it event.Skip();