From 0fd7a7f6b322fcf98297dbc64632e009afb6d4ac Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 31 Jan 2012 01:46:51 +0300 Subject: Add max chars limit for textfields. --- src/gui/widgets/textfield.cpp | 2 +- src/gui/widgets/textfield.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 03fdb5378..4ad02ccbb 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -193,7 +193,7 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent) { int val = keyEvent.getKey().getValue(); - if (val >= 32) + if (val >= 32 && (mNumeric || !mMaximum || mText.size() < mMaximum)) { int l; if (val < 128) diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index bc1123f19..fef606526 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -114,7 +114,7 @@ class TextField : public gcn::TextField static ImageRect skin; bool mNumeric; int mMinimum; - int mMaximum; + unsigned mMaximum; bool mLoseFocusOnTab; int mLastEventPaste; }; -- cgit v1.2.3-70-g09d2