Author: jcrowley
Date: 2007-09-26 21:20:51 -0700 (Wed, 26 Sep 2007)
New Revision: 6637

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/views/LzInputText.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/views/LzText.lzs
Log:
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.



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/views/LzInputText.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/views/LzInputText.lzs      2007-09-27 
02:28:06 UTC (rev 6636)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/views/LzInputText.lzs      2007-09-27 
04:20:51 UTC (rev 6637)
@@ -247,6 +247,9 @@
 function setText ( t ){
     // force to a string
     t += '';
+    if (this.maxlength != null && t.length > this.maxlength){
+        t = t.substring(0, this.maxlength);
+    }
     this.sprite.setText(t);
     this.text =  t;
     // [todo 2006-06 hqm] when should we send onwidth and onheight events?

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/views/LzText.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/views/LzText.lzs   2007-09-27 02:28:06 UTC 
(rev 6636)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/views/LzText.lzs   2007-09-27 04:20:51 UTC 
(rev 6637)
@@ -199,8 +199,15 @@
 
     this.resize = ('resize' in args) ? (args.resize == true) : this.resize;
     this.setResize(this.resize);
+    
+    if ('maxlength' in args && args.maxlength != null) {
+        this.setMaxLength(args.maxlength);
+    }
 
     this.text =  (!('text' in args) || args.text == null) ? "" : args.text;
+    if(this.maxlength != null && this.text.length > this.maxlength){
+        this.text = this.text.substring(0, this.maxlength);
+    }
 
     this.setMultiline( this.multiline );
 
@@ -243,10 +250,6 @@
     // Default the scrollheight to the visible height.
     this.scrollheight = this.height;
 
-    if ('maxlength' in args && args.maxlength != null) {
-        this.setMaxLength(args.maxlength);
-    }
-
     if ('pattern' in args && args.pattern != null) {
         this.setPattern(args.pattern);
     }
@@ -663,6 +666,9 @@
     t += '';
     if (force != true && t == this.text) return;
     if (this.visible) this.sprite.setVisible(this.visible);
+    if (this.maxlength != null && t.length > this.maxlength){
+        t = t.substring(0, this.maxlength);
+    }
     this.sprite.setText(t);
     this.text =  t;
 


_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Reply via email to