History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: LPP-5449
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: P0 P0
Assignee: Unassigned
Reporter: Pablo Kang
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
OpenLaszlo

Seems like inputtext selection position is not reset until input text is focused or setSelection() is invoked

Created: 19/Feb/08 03:24 PM   Updated: 13/Mar/08 08:29 AM
Component/s: LFC - Text
Affects Version/s: Freya
Fix Version/s: Mars, RingDing (4.1)

Time Tracking:
Not Specified

Severity: Major
Fixed in Change#: 8,203
Runtime: N/A
Fix in hand: False


 Description  « Hide
Test case:
<canvas debug="true">

    <constantlayout axis="x" value="10"/>
    <simplelayout spacing="10" inset="10"/>

    <inputtext id="input" width="100" bgcolor="gray"/>

   <!-- Set long text and set selection at the end -->
    <button text="set selection at end of text">
        <handler name="onclick">
            var text = "abcdefghijklmnopqrstuvwxyz";
            input.setText(text);
            input.setSelection(text.length);
        </handler>
    </button>

    <!-- Clear the text. -->
    <button text="clear text">
        <handler name="onclick">
            input.setText("");
        </handler>
    </button>

    <!-- Text will not appear after clicking this button until you focus on
         input. You could alternatively call setSelection. -->
    <button text="set text">
        <handler name="onclick">
            input.setText("x");
        </handler>
    </button>

</canvas>

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Max Carlson - 20/Feb/08 10:01 AM
This is also present for me under wafflecone. Is this actually a regression?

It's fairly easy to work around - just reset the selection when clearing out the text field:
...
    <!-- Clear the text. -->
    <button text="clear text">
        <handler name="onclick">
            input.setSelection(0);
            input.setText("");
        </handler>
    </button>
...

Pablo Kang - 21/Feb/08 08:01 PM
Max and I concluded that the right thing here is to set the selection at the end of the text if the selection is out of bound compared to the length of the text set.

Max Carlson - 06/Mar/08 02:15 PM
Author: max
Date: 2008-03-06 14:15:12 -0800 (Thu, 06 Mar 2008)
New Revision: 8202

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzInputTextSprite.as
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as
Log:
Change 20080306-maxcarlson-k by maxcarlson@Roboto on 2008-03-06 13:08:28 PST
    in /Users/maxcarlson/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Reset selection when when selection position is out of bounds

New Features:

Bugs Fixed: LPP-5449 - Seems like inputtext selection position is not reset until input text is focused or setSelection() is invoked

Technical Reviewer: promanik
QA Reviewer: pkang@laszlosystems.com
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details: LzTextSprite.as - Track selection position in setSelection. If the string passed to setText() is smaller than the selection, reset the selection.

LzInputTextSprite.as - If the string passed to setText() is smaller than the selection, reset the selection.
    

Tests: See LPP-5449



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzInputTextSprite.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzInputTextSprite.as 2008-03-06 21:59:05 UTC (rev 8201)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzInputTextSprite.as 2008-03-06 22:15:12 UTC (rev 8202)
@@ -298,6 +298,7 @@
   * @param String t: the string to which to set the text
   */
 LzInputTextSprite.prototype.setText = function ( t ){
+ // Keep in sync with LzTextSprite.setText()
     //Debug.write('LzInputTextSprite.setText', this, t);
     if (typeof(t) == 'undefined' || t == null) {
         t = "";
@@ -331,6 +332,12 @@
         LzIdle.callOnIdle(scrolldel);
     }
 
+ // Fix for lpp-5449
+ var l = t.length;
+ if (this._selectionstart > l || this._selectionend > l) {
+ this.setSelection(l);
+ }
+
     //@event ontext: Sent whenever the text in the field changes.
     //this.owner.ontext.sendEvent(t);
 }

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as 2008-03-06 21:59:05 UTC (rev 8201)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzTextSprite.as 2008-03-06 22:15:12 UTC (rev 8202)
@@ -1,7 +1,7 @@
 /**
   * LzTextSprite.as
   *
- * @copyright Copyright 2001-2007 Laszlo Systems, Inc. All Rights Reserved.
+ * @copyright Copyright 2001-2008 Laszlo Systems, Inc. All Rights Reserved.
   * Use is subject to license terms.
   *
   * @topic Kernel
@@ -461,6 +461,7 @@
   * @param String t: the string to which to set the text
   */
 LzTextSprite.prototype.setText = function ( t ){
+ // Keep in sync with LzTextSprite.setText()
     if (typeof(t) == 'undefined' || t == 'null') {
         t = "";
     } else if (typeof(t) != "string") {
@@ -496,6 +497,12 @@
         LzIdle.callOnIdle(scrolldel);
     }
 
+ // Fix for lpp-5449
+ var l = t.length;
+ if (this._selectionstart > l || this._selectionend > l) {
+ this.setSelection(l);
+ }
+
     //@event ontext: Sent whenever the text in the field changes.
     //this.ontext.sendEvent( );
 }
@@ -800,6 +807,10 @@
         end = start;
     }
 
+ // Fix for lpp-5449
+ this._selectionstart = start;
+ this._selectionend = end;
+
     Selection.setSelection( start , end );
 }
 


_______________________________________________
Laszlo-checkins mailing list
Laszlo-checkins@openlaszlo.org
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Mamye Kratt - 13/Mar/08 08:21 AM
(pagan-deities branch build r8223 - mars RC)

"set selection at end of text" button puts a thru z in the inputtext field and places the cursor after z
"clear text" button clears the text
"set text" button puts an x in the inputtext field with no cursor, when "set selection" button is chosen a thru z replaces the x in the inputtext field and places the cursor after z

I believe the test is working correctly. Waiting for Pablo to approve the fix.


Mamye Kratt - 13/Mar/08 08:26 AM
(trunk build r8223)
See previous comment.

Mamye Kratt - 13/Mar/08 08:27 AM
mars testing

Mamye Kratt - 13/Mar/08 08:29 AM
(pagan deities branch build 8203 mars RC)

Spoke with Pablo http://emma.laszlosystems.com/jira/browse/EM-5110 and http://emma.laszlosystems.com/jira/browse/EM-5025 are closed.