Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Later
-
Adobe Flex SDK 4.0 (Release)
-
None
-
None
-
Affected OS(s): All OS Platforms
Browser: Firefox 3.x
Language Found: English
Description
I have a Label that is being truncated with an ellipsis mark (...) and I would like to programmatically figure out how much width is being cut off.
In Group I would do something like (group.contentWidth - group.width), but there does not seem to be an equivalent concept in Label.
Example use case:
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Script>
<![CDATA[
public function figureOutExcess():void
]]
>
</fx:Script>
<s:Label id="lbl" width="100" maxDisplayedLines="1" text="Some long string which will get ellipsis'd" />
</s:Application>
Workaround:
From Gordon: "I don't think there is a property that tells you the untruncated width. I think you'd first have to set width to NaN and maxDisplayedLines to 0 in order to get the Label to render the text untruncated in a single line, wait for the updateComplete event, and read the measuredWidth. That should be the untruncated width. Then you could set width to 100 and maxDisplayedLines to 1."