Don't send EVT_TEXT_ENTER to controls without wxTE_PROCESS_ENTER

wxMSW always sent this event to multiline text controls, even when they
didn't have wxTE_PROCESS_ENTER style, contrary to what was documented.

Avoid sending this event unless wxTE_PROCESS_ENTER is used and add unit
tests checking that multiline text controls don't get it without this
style (but still do get it with it).
This commit is contained in:
Vadim Zeitlin
2019-09-08 18:50:02 +02:00
parent 4c075c2128
commit 84f29ce472
5 changed files with 84 additions and 5 deletions

View File

@@ -2075,14 +2075,18 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
switch ( event.GetKeyCode() )
{
case WXK_RETURN:
// Single line controls only get this key code if they have
// wxTE_PROCESS_ENTER style, but multiline ones always get it
// because they need it for themselves. However we shouldn't
// generate wxEVT_TEXT_ENTER for the controls without this style,
// so test for it explicitly.
if ( HasFlag(wxTE_PROCESS_ENTER) )
{
wxCommandEvent evt(wxEVT_TEXT_ENTER, m_windowId);
InitCommandEvent(evt);
evt.SetString(GetValue());
if ( HandleWindowEvent(evt) )
if ( !HasFlag(wxTE_MULTILINE) )
return;
//else: multiline controls need Enter for themselves
return;
}
break;