Hi,

Using the measured height and width of the text field and tweaking the 
multiline logic a little gives much better sizing results and fix the vertical 
height issue- also shows that one of the test is incorrect (text is truncated 
on a word boundary).

I still have 5 tests failing but that's 2 because the current images are 
incorrect (IMO) and show either truncated text or text over the buttons and 3 
because of minor anti antialiasing issues. It's still caching the textHeight 
and textWidth, however it was already using the cached text width before this 
patch.

Here's the patch. What do you think?

diff --git a/frameworks/projects/mx/src/mx/controls/alertClasses/AlertForm.as 
b/frameworks/projects/mx/src/mx/controls/alertClasses/AlertForm.as
index ce7e525..cfc8c47 100644
--- a/frameworks/projects/mx/src/mx/controls/alertClasses/AlertForm.as
+++ b/frameworks/projects/mx/src/mx/controls/alertClasses/AlertForm.as
@@ -296,7 +296,7 @@ public class AlertForm extends UIComponent implements 
IFontContextComponent
                // Set the textField to word-wrap if the text is more
                // than twice as wide as the buttons and title
                textField.width = 2 * buttonAndTitleWidth;
-               textWidth = textField.textWidth + 
UITextField.TEXT_WIDTH_PADDING;
+               textWidth = textField.measuredWidth;
 
                // Window is wider of buttons or text, but not more than twice 
as
                // wide as buttons.
@@ -305,12 +305,12 @@ public class AlertForm extends UIComponent implements 
IFontContextComponent
 
                // Need this because TextField likes to use multiple lines
                // even for single words.
-               if (textWidth < prefWidth && textField.multiline == true)
+               if (textWidth < prefWidth && textField.multiline)
                {
                        textField.multiline = false;
                        textField.wordWrap = false;
                }
-               else if (textField.multiline == false)
+               else if (textWidth > prefWidth && !textField.multiline)
                {
                        textField.wordWrap = true;
                        textField.multiline = true;
@@ -323,7 +323,7 @@ public class AlertForm extends UIComponent implements 
IFontContextComponent
                        prefWidth += icon.width + 8;
 
                // Make height tall enough for text and icon.
-               textHeight = textField.textHeight + 
UITextField.TEXT_HEIGHT_PADDING;
+               textHeight = textField.measuredHeight;
                var prefHeight:Number = textHeight;
 
                if (icon)
@@ -331,6 +331,8 @@ public class AlertForm extends UIComponent implements 
IFontContextComponent
 
                // Limit the height if it exceeds the height of the Stage.
                prefHeight = Math.min(prefHeight, screen.height * 0.75);
+               textHeight = Math.min(textHeight, prefHeight);
+                       
                // Add space for buttons, spacing between buttons and text,
                // and top/bottom margins
                prefHeight += buttons[0].height + (3 * 8);
@@ -377,10 +379,9 @@ public class AlertForm extends UIComponent implements 
IFontContextComponent
                        icon.y = (newY - icon.height) / 2;
                        newX += icon.width + 8;
                }
-
-               var newHeight:Number = textField.getExplicitOrMeasuredHeight();
-               textField.move(newX, Math.round((newY - newHeight) / 2));
-               textField.setActualSize(textWidth+5, newHeight);
+               
+               textField.move(newX, Math.round((newY - textHeight) / 2));
+               textField.setActualSize(textWidth+5, textHeight);
        }
 
     /**

Thanks,
Justin

Reply via email to