From bdf0c19c6e8e1adf406a647d65eae781f6417c8c Mon Sep 17 00:00:00 2001 From: Kevin Hock Date: Thu, 2 Dec 2004 21:35:40 +0000 Subject: [PATCH] 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 --- src/mac/carbon/textctrl.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index d1b9fa2325..3b06665ebf 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -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; -- 2.50.0