You may want to change this line:
if(this.maxlength && this.text.length > this.maxlength){
to:
if(this.maxlength != null && this.text.length > this.maxlength){
because 0 == false, so maxlength == 0 would not work. Then again, what
good is a textfield with a maxlength of 0?
Approved!
J Crowley wrote:
Change 20070926-jcrowley-r by [EMAIL PROTECTED] on
2007-09-26 05:45:59 EDT
in /Users/jcrowley/src/svn/openlaszlo/trunk-a
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: maxlength doesn't work for LzText (NOTE: also fixed
for inputtext)
New Features:
Bugs Fixed: LPP-2208 - maxlength doesn't work for LzText
Technical Reviewer: pbr
QA Reviewer: max
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details: Added a check for maxlength to setText() functions
in both LzText and LzInputText. Also fixed it for
initial text construction. If maxlength is set,
text will not exceed the length, even with setText().
(Before this, it would catch it with inputtext,
but only when one entered text into the box.
setText() would ignore it.)
Tests: Run the following:
<canvas width="500" height="500">
<simplelayout axis="y"/>
<text id="tx1" text="This text shouldn't be truncated."/>
<text id="tx2" text="This text should be truncated after 12
characters." maxlength="12"/>
<inputtext id="tx3" text="Type something here fdafda."
maxlength="20" width="300"
bgcolor="0xDDFFDD"/>
<button
onclick="tx1.setText('This text is pretty long, but it should be
fine.')">
Click here to set the first text element using setText()
</button>
<button
onclick="tx2.setText('This text is much longer than the allowed
limit of twelve characters.')">
Click here to set the second text element using setText()
</button>
<button
onclick="tx3.setText('This text is much longer than the allowed
limit of twenty characters.')">
Click here to set the inputtext using setText()
</button>
</canvas>
This also passes smokecheck, and actually clears up
a failure in the lztest-text test.
Files:
M WEB-INF/lps/lfc/views/LzInputText.lzs
M WEB-INF/lps/lfc/views/LzText.lzs
Changeset:
http://svn.openlaszlo.org/openlaszlo/patches/20070926-jcrowley-r.tar
--
Regards,
Max Carlson
OpenLaszlo.org