don't eat all events if m_maxLength is 0: this means no limit according to the docs and both wxMSW and wxGTK behave like this

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37187 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-01-27 23:05:23 +00:00
parent 2ca2357ded
commit b9bae707bb

View File

@@ -401,8 +401,6 @@ private :
#endif
};
#define TE_UNLIMITED_LENGTH 0xFFFFFFFFUL
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
@@ -435,7 +433,7 @@ void wxTextCtrl::Init()
m_editable = true ;
m_dirty = false;
m_maxLength = TE_UNLIMITED_LENGTH ;
m_maxLength = 0;
m_privateContextMenu = NULL;
}
@@ -895,13 +893,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 &&
// Check if we have reached the max # of chars (if it is set), but still
// allow navigation and deletion
if ( !IsMultiLine() && m_maxLength && 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
// TODO: generate EVT_TEXT_MAXLEN()
return;
}