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:
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user