incubator-flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cframp...@apache.org
Subject svn commit: r1414954 - /incubator/flex/sdk/branches/develop/frameworks/projects/framework/src/mx/core/UITextField.as
Date Wed, 28 Nov 2012 21:58:45 GMT
Author: cframpton
Date: Wed Nov 28 21:58:45 2012
New Revision: 1414954

URL: http://svn.apache.org/viewvc?rev=1414954&view=rev
Log:
>From whiteboard/cframpton/adobe.next.  Fix truncateToFit so it makes a best guess on where
to start the truncation rather than starting at the end of the string. This was always the
intent but it was buggy.  SDK-26166.

Modified:
    incubator/flex/sdk/branches/develop/frameworks/projects/framework/src/mx/core/UITextField.as

Modified: incubator/flex/sdk/branches/develop/frameworks/projects/framework/src/mx/core/UITextField.as
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/frameworks/projects/framework/src/mx/core/UITextField.as?rev=1414954&r1=1414953&r2=1414954&view=diff
==============================================================================
--- incubator/flex/sdk/branches/develop/frameworks/projects/framework/src/mx/core/UITextField.as
(original)
+++ incubator/flex/sdk/branches/develop/frameworks/projects/framework/src/mx/core/UITextField.as
Wed Nov 28 21:58:45 2012
@@ -2434,10 +2434,16 @@ public class UITextField extends FlexTex
         if (originalText != "" && textWidth + TEXT_WIDTH_PADDING > w + 0.00000000000001)
         {
             // This should get us into the ballpark.
-            var s:String = super.text = originalText;
+            var s:String = 
                 originalText.slice(0,
                     Math.floor((w / (textWidth + TEXT_WIDTH_PADDING)) * originalText.length));
 
+            // This doesn't seem correct but it preserves previous behavior.
+            // If one character doesn't fit the text is one character plus the
+            // truncation indicator rather than just the truncation indicator as you would
expect.
+            if (s.length <= 1 && textWidth + TEXT_WIDTH_PADDING > w)
+                super.text = originalText.charAt(0) + truncationIndicator;
+            
             while (s.length > 1 && textWidth + TEXT_WIDTH_PADDING > w)
             {
                 s = s.slice(0, -1);



Mime
View raw message