06-11-2012 09:55 PM
Hey,
I noticed "Label" and "TextArea" both behave differently by default, neither accomplishing what I'd like. I'm wondering if there's some easy way to make them behave appropriately.
Firstly, can I force a label to line-wrap? I've given the element plenty of extra height to fit two lines of text but the element refuses to wrap, instead ending with "..." (which would be great behavior if it would use the entirety of it's height first).
Secondly, since I can't make labels wrap, can I make TextArea behave like a Label and treat the overflow with a "...". Also, TextArea seems to be adding some stealth margin to itself. I am using TextArea with editable:false.
If I switch some text from a "TextArea" to a "Label" with the attributes:
layoutProperties: AbsoluteLayoutProperties {
positionX: 125.0
positionY: 15.0
}
leftMargin: 0.0
rightMargin: 0.0
the TextArea renders farther right than the Label, I'd guess 10-20 pixels.
The elements having different default margins seems reasonable to me, however rendering differently when margin is explicitly stated is less than ideal, I'd hope the defaults would be overrode in such a case.
Perhaps a suggestion as to the Label documentation, as I believe it is functioning as intended, is to explicitly state it will only render one line of text. These points made it seem otherwise (from the Label docs):
- By default, the height of the control is adjusted automatically to fit one line of text.
- The height is adjustable using the Control:
referredHeight, Control::minHeight and Control::maxHeight and properties.
These two points lead me to believe that if I explicitly state a height I could adjust the control to accept more than one line of text, since I'd be overriding the default.
Perhaps there's a TextStyleDefinition that could make a TextArea render more like a Label?
06-15-2012 11:33 AM
Hey Brennan,
It's not currently possible to line wrap a Label, they can only be a single line. It's also currently not possible to treat the overflow of a TextArea with "...".
Tim
06-15-2012 11:05 PM
Alright, thanks for the info.
Using two labels, one on top of the other, then splitting the string in some educated way to fill the two labels, seems like my best bet. However, I'm not sure how I could split the string in any educated way.
I suppose I could find the longest letter in the font, find the max possible amount of characters the label could fit in the worst case scenario based on that letter length, and then split the string based on that length.
It's too bad TextStyleDefinition doesn't have a string measure function.
- Brennan
06-19-2012 08:45 AM
Hey there,
I definitely see the use case for something like this. I would recommend logging a new Feature Request in the Issue Tracker by following the link:
https://www.blackberry.com/jira/secure/Dashboard.j
Please make sure to describe a specific use case in order to help us understand the context.
Thanks!
Martin