flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmcl...@apache.org
Subject git commit: [flex-sdk] [refs/heads/develop] - FLEX-24257 Fixed measured width of date field as it may vary month by month based on format.
Date Tue, 18 Jun 2013 11:00:29 GMT
Updated Branches:
  refs/heads/develop 965ec7616 -> 04b8b35ca


FLEX-24257 Fixed measured width of date field as it may vary month by month based on format.


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/04b8b35c
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/04b8b35c
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/04b8b35c

Branch: refs/heads/develop
Commit: 04b8b35ca28eb74323032ce3835944e6064a8902
Parents: 965ec76
Author: Justin Mclean <jmclean@apache.org>
Authored: Tue Jun 18 20:58:45 2013 +1000
Committer: Justin Mclean <jmclean@apache.org>
Committed: Tue Jun 18 20:58:45 2013 +1000

----------------------------------------------------------------------
 .../projects/mx/src/mx/controls/DateField.as     | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/04b8b35c/frameworks/projects/mx/src/mx/controls/DateField.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/mx/src/mx/controls/DateField.as b/frameworks/projects/mx/src/mx/controls/DateField.as
index 9c65abc..e78074b 100644
--- a/frameworks/projects/mx/src/mx/controls/DateField.as
+++ b/frameworks/projects/mx/src/mx/controls/DateField.as
@@ -2203,11 +2203,22 @@ public class DateField extends ComboBase
         var buttonWidth:Number = downArrowButton.getExplicitOrMeasuredWidth();
         var buttonHeight:Number = downArrowButton.getExplicitOrMeasuredHeight();
 
-        var bigDate:Date = new Date(2004, 12, 31);
-        var txt:String = (_labelFunction != null) ? _labelFunction(bigDate) : 
-                            dateToString(bigDate, formatString);
+        var bigDate:Date;
+        var txt:String;
+		var textWidth:Number;
+		var maxWidth:Number = 0;
+		
+		// Width may vary based on date format
+		for (var month:int = 0; month < 12; month++) {
+			bigDate = new Date(2000, month, 28); // day 28 exist in all months
+			txt = (_labelFunction != null) ? _labelFunction(bigDate) : dateToString(bigDate, formatString);
+			textWidth = measureText(txt).width;
+			if (textWidth > maxWidth) {
+				maxWidth = textWidth;
+			}
+		}
 
-        measuredMinWidth = measuredWidth = measureText(txt).width + 8 + 2 + buttonWidth;
+        measuredMinWidth = measuredWidth = maxWidth + 8 + 2 + buttonWidth;
         measuredMinWidth = measuredWidth += getStyle("paddingLeft") + getStyle("paddingRight");
         measuredMinHeight = measuredHeight = textInput.getExplicitOrMeasuredHeight();
     }


Mime
View raw message