Don't activate default button on Enter in multiline wxTextCtrl

Restore behaviour until c43e0fa123 and let
Enter presses in multiline text controls perform their default function
in the control instead of closing the dialog.

Make the unit test more discerning to check for this.
This commit is contained in:
Vadim Zeitlin
2019-09-08 22:05:58 +02:00
parent 84f29ce472
commit 9bab9d8da8
2 changed files with 7 additions and 5 deletions

View File

@@ -2216,7 +2216,7 @@ wxTextCtrl::MSWHandleMessage(WXLRESULT *rc,
// 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 ( !processed && wParam == VK_RETURN && IsSingleLine() )
{
if ( ClickDefaultButtonIfPossible() )
processed = true;

View File

@@ -443,8 +443,10 @@ private:
{
case ProcessEnter_No:
case ProcessEnter_ButSkip:
// We consider that the text succeeded.
EndModal(wxID_OK);
// We consider that the text succeeded, but in a different way,
// so use a different ID to be able to distinguish between this
// scenario and Enter activating the default button.
EndModal(wxID_CLOSE);
break;
case ProcessEnter_WithoutSkipping:
@@ -521,7 +523,7 @@ void TestProcessEnter(const TextLikeControlCreator& controlCreator)
return;
TestDialog dlg(*multiLineCreator, ProcessEnter_No);
REQUIRE( dlg.ShowModal() == wxID_OK );
REQUIRE( dlg.ShowModal() == wxID_CLOSE );
CHECK( !dlg.GotEnter() );
}
@@ -533,7 +535,7 @@ void TestProcessEnter(const TextLikeControlCreator& controlCreator)
return;
TestDialog dlg(*multiLineCreator, ProcessEnter_ButSkip);
REQUIRE( dlg.ShowModal() == wxID_OK );
REQUIRE( dlg.ShowModal() == wxID_CLOSE );
CHECK( dlg.GotEnter() );
}