Uploaded image for project: 'Apache Flex'
  1. Apache Flex
  2. FLEX-23005

Need a way to calculate the width of a Label that has been cut off by truncation

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Later
    • Adobe Flex SDK 4.0 (Release)
    • None
    • Spark: Label
    • 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

      { // i want to know how much of this Label is being hidden behind the ... // Ideally something like ... // trace(lbl.contentWidth - lbl.width); }

      ]]
      >
      </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."

      Attachments

        Activity

          People

            adobejira Adobe JIRA
            adobejira Adobe JIRA
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: