I found the problem. It was in two parts:
1) The default tooltip wraps to 300px, even if the application is
narrower than that.
2) There's a bug in ToolTip.measure, which causes wrapping to be done
incorrectly some of the time. It's a > instead of >=.
To fix both of these, I overrode ToolTip.measure():
// Note: These lines are required to be able to access "border"
//import mx.core.mx_internal;
//use namespace mx_internal;
override protected function measure():void
{
super.measure();
// This section is my addition. Always set the maxWidth
// to the application's maxWidth.
var maxW:Number = Application.application.width - 2;
if (maxW > this.maxWidth)
maxW = this.maxWidth;
// Same as ToolTip.borderMetrics
var bm:EdgeMetrics = border is IRectangularBorder ? IRectangularBorder
(border).borderMetrics : EdgeMetrics.EMPTY;
var leftInset:Number = bm.left + getStyle("paddingLeft");
var topInset:Number = bm.top + getStyle("paddingTop");
var rightInset:Number = bm.right + getStyle("paddingRight");
var bottomInset:Number = bm.bottom + getStyle("paddingBottom");
var widthSlop:Number = leftInset + rightInset;
var heightSlop:Number = topInset + bottomInset;
textField.wordWrap = false;
// The original code had this as > instead of >=. That's a bug.
if (textField.textWidth + widthSlop >= maxW)
{
textField.width = maxW - widthSlop;
textField.wordWrap = true;
}
measuredWidth = textField.width + widthSlop;
measuredHeight = textField.height + heightSlop;
}
--- In [email protected], "whatabrain" <[EMAIL PROTECTED]> wrote:
>
> I'm working with a very narrow app, so tooltips are sometimes wider
> than the app.
>
> How do I add word-wrap to tooltips?
>