|
|
|
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.
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: 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 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 (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. (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. |
||||||||||||||||||||||||||||||||||||||||||||||||||||
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>
...