Merge remote-tracking branch 'sunset/process-enter'

Fix wxTE_PROCESS_ENTER logic for wxMSW and wxGTK too.

See https://github.com/wxWidgets/wxWidgets/pull/1415

Closes #18273.
This commit is contained in:
Vadim Zeitlin
2019-07-26 18:02:08 +02:00
14 changed files with 260 additions and 27 deletions

View File

@@ -2199,29 +2199,26 @@ wxTextCtrl::MSWHandleMessage(WXLRESULT *rc,
{
bool processed = wxTextCtrlBase::MSWHandleMessage(rc, nMsg, wParam, lParam);
// Handle the special case of "Enter" key: the user code needs to specify
// wxTE_PROCESS_ENTER style to get it in the first place, but if this flag
// is used, then even if the wxEVT_TEXT_ENTER handler skips the event, the
// normal action of this key is not performed because IsDialogMessage() is
// not called and, also, an annoying beep is generated by EDIT default
// WndProc.
//
// Fix these problems by explicitly performing the default function of this
// key (which would be done by MSWProcessMessage() if we didn't have
// wxTE_PROCESS_ENTER) and preventing the default WndProc from getting it.
if ( nMsg == WM_CHAR &&
!processed &&
HasFlag(wxTE_PROCESS_ENTER) &&
wParam == VK_RETURN &&
!wxIsAnyModifierDown() )
{
MSWClickButtonIfPossible(MSWGetDefaultButtonFor(this));
processed = true;
}
switch ( nMsg )
{
case WM_CHAR:
// Handle the special case of "Enter" key: the user code needs to specify
// wxTE_PROCESS_ENTER style to get it in the first place, but if this flag
// is used, then even if the wxEVT_TEXT_ENTER handler skips the event, the
// normal action of this key is not performed because IsDialogMessage() is
// not called and, also, an annoying beep is generated by EDIT default
// WndProc.
//
// Fix these problems by explicitly performing the default function of this
// key (which would be done by MSWProcessMessage() if we didn't have
// wxTE_PROCESS_ENTER) and preventing the default WndProc from getting it.
if ( !processed && wParam == VK_RETURN )
{
if ( ClickDefaultButtonIfPossible() )
processed = true;
}
break;
case WM_GETDLGCODE:
{
// Ensure that the result value is initialized even if the base