Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
joetesta
Roku Guru

Point at which label isTextEllipsized

Hello -
I have a paragraph of text displayed as a Label Component and we want to put a "more" button at the end of the text on the 4th line.  The more button should appear within the rectangle that contains the paragraph, and the ellipsis should appear before (to the left of) the more button.

There's no simple way to do this with Label Component but if I can tell at what point the text "isTextEllipsized" then I can modify the original text to display as needed.

The brute says increment over every letter in the paragraph to see at what point isTextEllipsized first becomes true. But hopefully there's a better way? 
Any ideas or suggestions?
tyvmia
aspiring
0 Kudos
8 REPLIES 8
destruk
Binge Watcher

Re: Point at which label isTextEllipsized

I'm thinking if you can assign a custom monospaced font - that way you can fill your label with text and you know exactly how many characters will fit before the ellipse.  Then you would simply break the display on a space when it would otherwise overflow.
0 Kudos
joetesta
Roku Guru

Re: Point at which label isTextEllipsized

"destruk" wrote:
I'm thinking if you can assign a custom monospaced font - that way you can fill your label with text and you know exactly how many characters will fit before the ellipse.  Then you would simply break the display on a space when it would otherwise overflow.

Thanks destruk 🙂 on this project I do not have the luxury to choose the font.
aspiring
0 Kudos
destruk
Binge Watcher

Re: Point at which label isTextEllipsized

Along the same lines - work out how many pixels each character in the font you are using takes horizontally, and then go through and accumulate/add up the widths of all the characters and split at the break point where it becomes ellipsized?  It's more work but shouldn't take long for roku to cycle through.  It would be easier to do this using multiple labels if you have a label large enough to wrap text but you'd basically be working it out and handling your own text display.  There really ought to be a better solution.
0 Kudos
destruk
Binge Watcher

Re: Point at which label isTextEllipsized

Just off the top of my head, if the roku firmware was changed to have an 'isellipsed' value whenever there is a firmware-controlled ellipse shown, as well as the last character position (numeric) of the text that was displayed prior to the ellipse, and both could be read as needed, that would solve the issue.  There shouldn't be any reason to display the whole thing in a larger box for secondary display - just the 'more' part you need when more is selected.  Of course you could use the 'scrollinglabel' instead of a standard label - that way when too much text is displayed when the user waits a few seconds it fades and scrolls the rest for them without a more option required.
0 Kudos
destruk
Binge Watcher

Re: Point at which label isTextEllipsized

ScrollingLabel only works for a single horizontal line - for something like what you have with 4 lines it looks like ScrollableText would be more appropriate -
https://sdkdocs.roku.com/display/sdkdoc/ScrollableText
0 Kudos
joetesta
Roku Guru

Re: Point at which label isTextEllipsized

"destruk" wrote:
ScrollingLabel only works for a single horizontal line - for something like what you have with 4 lines it looks like ScrollableText would be more appropriate -
https://sdkdocs.roku.com/display/sdkdoc/ScrollableText

Thanks destruk - I intend to use that once the "more" button is clicked.  I do not have any flexibility in the design, I'm following detailed specs. 
What you mentioned above was the same thought I just had, if the firmware would make available a read only integer representing the position that the ellipsization happens, that would be great!

Now I'm trying to add the characters one by one until the isTextEllipsized observer is triggered, then see how many letters had been added up to that point, but it always returns the length of the full string.   Maybe I can do the opposite, strip letters off until isTextEllipsized goes back to false?  Will try...
aspiring
0 Kudos
destruk
Binge Watcher

Re: Point at which label isTextEllipsized

Maybe a constantly running timer task would help to set the display letter by letter? - if you set it to a small enough interval to give you a callback for when it's triggered?
0 Kudos
joetesta
Roku Guru

Re: Point at which label isTextEllipsized

There seems to be a substantial lag between setting the text and isTextEllipsized observer being triggered.It seems I will need to create a custom component that relies on font.GetOneLineWidth and replicate the needed functionality of Label.
All because the firmware / Label component can't tell where it was ellipsized. What a PITA.
aspiring
0 Kudos