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: 
youssefsherif
Streaming Star

how can i use the bounding rect

Jump to solution

how can i use the bounding rect to obtain width and height to be dynamically used in label?

0 Kudos
1 Solution

Accepted Solutions
renojim
Community Streaming Expert

Re: how can i use the bounding rect

Jump to solution

It's not clear what you're asking.  Set the label text to something and then use boundingRect() to get the size of the label as displayed on the screen:

label = CreateObject("roSGNode", "Label")
label.text = "Some text"
w = label.BoundingRect().width
h = label.BoundingRect().height

If you've set the label's width and height to something then BoundingRect() will just return those values.

Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.

View solution in original post

0 Kudos
2 REPLIES 2
renojim
Community Streaming Expert

Re: how can i use the bounding rect

Jump to solution

It's not clear what you're asking.  Set the label text to something and then use boundingRect() to get the size of the label as displayed on the screen:

label = CreateObject("roSGNode", "Label")
label.text = "Some text"
w = label.BoundingRect().width
h = label.BoundingRect().height

If you've set the label's width and height to something then BoundingRect() will just return those values.

Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
youssefsherif
Streaming Star

Re: how can i use the bounding rect

Jump to solution

thank you so much

0 Kudos