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:
Kevin Hock
2004-12-02 21:35:40 +00:00
parent 2b138cc2bd
commit bdf0c19c6e

View File

@@ -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;