Honor value of SetMaxLength, at least when typing (pasting still circumvents it). This is done by eating non-navigation/delete characters in OnChar.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30847 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -791,6 +791,16 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
|
||||
return ;
|
||||
}
|
||||
|
||||
// Check if we have reached the max # of chars, but still allow navigation and deletion
|
||||
if ( !IsMultiLine() && GetValue().Length() >= m_maxLength &&
|
||||
key != WXK_LEFT && key != WXK_RIGHT && key != WXK_TAB &&
|
||||
key != WXK_BACK && !( key == WXK_RETURN && (m_windowStyle & wxPROCESS_ENTER) )
|
||||
)
|
||||
{
|
||||
// eat it, we don't want to add more than allowed # of characters
|
||||
return;
|
||||
}
|
||||
|
||||
// assume that any key not processed yet is going to modify the control
|
||||
m_dirty = true;
|
||||
|
||||
|
Reference in New Issue
Block a user