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: 
jedashford
Channel Surfer

How do I get xy coordinates of a scene graph component?

I'm trying to overlay a spinner over a component that is dynamically placed so I don't have the x/y coords. Any idea how I can get the x/y values?

m.spinner.translation = [m.buttongroup.BoundingRect().x,m.buttongroup.BoundingRect().y]


This is what I get for the BoundingRect object, which is horribly incorrect:
{
height: 0
width: 0
x: 2.14748e+09
y: 2.14748e+09
}
0 Kudos
4 REPLIES 4
Skrzypu
Visitor

Re: How do I get xy coordinates of a scene graph component?

Hi,

You should check translation argument. I mean all components keeps their x,y value in translation argument.
So you should read translation argument from component that you are interested in.
0 Kudos
jedashford
Channel Surfer

Re: How do I get xy coordinates of a scene graph component?

Seems to still show crazy numbers:
Translation <Component: roArray> =
[
-2.14748e+09
-2.14748e+09
]

I tried translation from a few components, but many show as 0,0. My guess is that since I'm not setting the translation on any items, there are no values in the translation. I'm using layout groups to display everything dynamically:

<LayoutGroup
id="buttonLayoutGroup2"
itemSpacings="[200]"
horizAlignment = "center"
vertAlignment = "top"
layoutDirection="horiz" >
0 Kudos
jedashford
Channel Surfer

Re: How do I get xy coordinates of a scene graph component?

Anyone else needed to get coordinates of something on the screen in a scene graph component?
0 Kudos
jedashford
Channel Surfer

Re: How do I get xy coordinates of a scene graph component?

Got a little help from the inside. This does return correct info, but cannot be accessed until after UI is loaded. I can't find anything that would indicate when a component is loaded, other than posters which have a loadStatus, but not sure if that would even work. We almost need a 'renderStatus' interface for every component.

In my case I need it after a user clicks on a button which is well after everything is loaded. So at that point I get correct info below. If you needed while building the UI, My guess is you'd need to set up a timer and guess when the UI would be fully loaded and then update the UI.

m.mainButtongroup.boundingRect() will return this:

{
height: 396
width: 466
x: 0
y: 174
}
0 Kudos