How can I ellipsis a Text in BB 10 Cascades?

612 Views Asked by At

I'm developing a BlackBerry 10 mobile application using the Momentics IDE (native SDK).

I have a Label which has fixed width. If a Text does not fit in this Label, I want it to be ellipsis (elliding the text with the conventional "..." at the end) in place of a fade effect (just sort of "ghosts" into oblivion) like the Cascades designers have chosen to be in such case like presented in the image below.

Can any one help me on this ?

enter image description here

2

There are 2 best solutions below

1
On

Which version of QML? QML element Text has elide property and this is what you want.

0
On

Since Peter doesn't seem to know how to do this in a straight forward way, the only option left would seem to be the complicated way. You may, of course, create your own control and manage the text rendering in the way you would like using an ellipsis instead of the fade. That would seem to be a great deal of work for what in the end will really only result in your program being unconventional on the platform.

Edit:

Since you think it is worth a bounty I will add the following thought.

Using the ellipsis method, instead of the fade method, may impose a performance penalty on your application. Elliding text requires the computation of how many characters may be displayed int the available area and still leave room for the ellipsis. This is not a trivial mater with variable width type faces or different character sets. The fade, on the other hand, is a simple transparency operation. Since UI graphics operations in Cascades are all done in hardware the fade is quite efficient and independent of the size of the string, text area, type face, etc.