Merge branch 'multiline-enter-fix'
Fix handling Enter in multiline text controls in wxMSW. And other improvements, notably don't send wxEVT_TEXT_ENTER for controls without wxTE_PROCESS_ENTER style. Closes #18491. See https://github.com/wxWidgets/wxWidgets/pull/1539
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;
|
||||
|
||||
@@ -2212,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;
|
||||
|
||||
Reference in New Issue
Block a user