Search code examples
apache-flextextarea

Need flex textarea to wrap mid-words


I have a textarea with some long names in it (50+ characters).

I set the textAlign property to 'justify', and it wrap every thing well, except for those very long names.

This is how I define my textArea

<s:TextArea 
    id="textField"
    textAlign="justify"
    editable="false"
    styleName="ReadOnly"
    width="100%"
    height="100%"
    verticalScrollPolicy="auto"/>

I have something like (unwrapped):

Name: BAL-BLALBLALBL:ABLABLL:BALBALBLABLALBLBLB:LALB

What I expect to see it

Name: BAL-BLALBLALB
L:ABLABLL:BALBALBLA
BLALBLBLB:LALB

What I get instead is (with the extra spaces between Name and the beginning of the name):

Name:          BAL-
BLALBLALBL:ABLABLL:
BALBALBLABLALBLBLB:
LALB

It is those extra spaces that really annoy me.

But I remember seeing something somewhere about being able to cut the text mid-word instead of at the blank space or special characters

And I do not want to have to check for the size of the name and split it myself.

I am OK with changing the TextArea to something else as long as the new control support text selection (but not editing)


Solution

  • Set breakOpportunity="none" in the TextArea. For example:

    <s:TextArea 
         id="textField"
         textAlign="justify"
         editable="false"
         styleName="ReadOnly"
         width="100%"
         height="100%"
         verticalScrollPolicy="auto"
         breakOpportunity="none"/>