Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Trusted Contributor
Brennan12325
Posts: 204
Registered: ‎05-15-2012
My Device: None
My Carrier: Telus

Text Components

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::smileytongue: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?

 

 

----------------------
Check out my app, Alien Flow for reddit

And of course, like my post if you found it helpful or informative!
Please use plain text.
BlackBerry Development Advisor (Retired)
timvito
Posts: 19
Registered: ‎05-07-2012
My Device: none
My Carrier: none

Re: Text Components

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

Please use plain text.
Trusted Contributor
Brennan12325
Posts: 204
Registered: ‎05-15-2012
My Device: None
My Carrier: Telus

Re: Text Components

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

----------------------
Check out my app, Alien Flow for reddit

And of course, like my post if you found it helpful or informative!
Please use plain text.
BlackBerry Development Advisor (Retired)
mgoulet
Posts: 329
Registered: ‎05-07-2012
My Device: BB Alpha
My Carrier: N/A

Re: Text Components

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.jspa

 



Please make sure to describe a specific use case in order to help us understand the context.



 

Thanks!

 



Martin


 

Please use plain text.