Hi, is there any way to get the position (x, y) of a certain child in a grid panel?
Thanks.
Hi, is there any way to get the position (x, y) of a certain child in a grid panel?
Thanks.
Desired Size
)With all the above, you can math it out. If you’re not sure how, do it on a sheet of paper and translate into BP nodes. Which will feel a bit backwards at first…
It gets a tad trickier when you have a non-uniform grid.
You can use something like this but it depends on what you’re trying to do, for example are you trying to take the viewport size into consideration or just the space within the panel.
Before you jump on the Cached Geometry
bandwagon, do read its tooltip. If you’re OK with it, that could work, too.
Thanks. I’m just trying to take the grid space into consideration.
Thanks a lot. But how can I get the child in a certain cell, considering I know the row/column? “Get child at” node only has an index.
You surely know the number of rows / columns. Modulo helps, but it can be done the hard way, too.
How would you find out the index, if you know the row and column of the cell, through modulo though? I can’t figure it out.
I see a lot of confusion on this page. And multiple questions that differ from what it initially was.
How to get XY pixel position has been answered above.
How to get XY in “grid space” (row + column) is possible when every item on the grid has a uniform size, so that you can say “A row of 100px is made of 5 items of 20px”, then it’s easy enough to get a X or Y index in grid space, if your pixel position of the item is at 80 pixels then it is at index 4 (count indexes 0 1 2 3 4, indexes always start at 0).
If you have only the index of the item, you can calculate the row and column position the easiest using modulo.
If you have rows sized 5 columns, 76 items on it would give you?
You get 15 full rows and a column extra.
row index 15, column index 0.
Modulo gives you a remainder of a division, which is your “extra column(s)”.
Because modulo is not used for that. If you know the row and column you do:
(RowSize * RowIndex) + ColumnIndex
Basically you fill imaginary rows by their maximum size and add the remaining columns.