3 Replies Latest reply on Jan 29, 2007 2:22 PM by Craig Grummitt

    multiline label

    Craig Grummitt Level 3
      The labels for my formItems are sometimes too long for one line, and pointing to the label to see a tooltip display the full title is insufficient for my client's requirements. There is room on the stage for the label to wrap over two lines, but according to docs labels does not support multiline.

      i've considered two solutions to this, both of which i would prefer to avoid:

      1. creating my own custom formitem component from scratch with a multiline text control.

      2. coloring the label in the formItem the same color as the background and absolutely positioning a multiline text control where the label should be (time is short!)

      can anyone think of a simpler way around this problem?
      cheers
      Craig
        • 1. Re: multiline label
          Craig Grummitt Level 3
          before the rush of responses which is sure to arrive at some stage ;-) , i thought i should let you know that this ain't as urgent any more as i've just gone with the fudge - option 2)
          • 2. Re: multiline label
            peterent Level 2
            Unfortunately, FormItem's label is just that, a Label. And Labels are not multi-line. But FormItem's actually use FormItemLabel, not Label directly. So you can write your own FormItemLabel and extend it from Text, not Label.

            1. create the package mx.controls in YOUR application path.
            2. create FormItemLabel.as in that package. Extend Text.
            3. Override the protected function measure(), call super.measure(), then adjust measuredWidth and measuredHeight.

            You'll have to experiment in the measure() function to get those values correct. The alternative is to explictly size the FormItem which is probably your best bet for accuracy.

            By placing mx.controls.FormItemLabel in your application path, the Flash Player will load your FormitemLabel first and ignore the one in the frameworks.swc.

            Disclaimer: I haven't tried this myself (it should work, though). And if you break Flex, well, you'll have to go with plan B.
            • 3. Re: multiline label
              Craig Grummitt Level 3
              very interesting advice peter. i hadn't considered(or even knew how) to modify the standard controls rather than needing to create new ones.

              i had already gone with another solution by this stage but i know that this advice will come in very handy in the future. thanks for that.

              Craig