# Creating widgets for seperate rows of a uniform box with binds?

Hey there,

I feel I have what is an easy question and cant figure it out.

Essentially, I’m creating widgets with buttons and adding them as a child to a uniform box.

The problem is, I want half to be on row 0 and half on row 1.

If i sequence it, It looks correct but now I cant bind an event without issue.

If I dont sequence it, all 10 get stuck on the same row but the binds work perfectly.

Anyone got any ideas?

Thank yeee

Are you adding the child buttons from the design tab? Or is it being added through blueprint logic?

Also sharing a screenshot of your bind event implementation should make it easier to figure out the issue.

Hey,

Sorry, I was in a blind rush and frustratingly wacked this up.

It’s being added through blueprint logic.

This link seems to be the code I need, but unreal has changed since this post slightly.

So I think it should still work. I just can’t figure it out the maths.

So far I can get the result by using a sequence and running 2 of the for each loop ermm collection of nodes.

But it means you can only reference the top or bottom line of code for use of the button.

Alright, so you can get that working by adding in the two divide operations from the following code:

I just divided it by 5 since that’s the number of elements you mentioned being in a single row. You can replace it with any other number if you want to change the number of buttons in a row.

1 Like

This is 1000% it.

Omg, thank you.

I always thought maths was my strong suit, but I’m really struggling to understand it.

We are dividing and finding a percent of the input of the array index. Which is 0 through 9.

On the first loop it’s zero, divide by 5 = 0 and 0 % 5 is 0

second loop, is one which be 0.2 and 0.05

etc

Division
Now it gets interesting at loop 5 as it’s now equal to one, so it places its self on the next row. The division of rows makes perfect sense. (Assuming anything under 1 just immediately gets rounded to row 0.)

So all the decimals are ignored as the uniform grid works in integer, they are slotted into row 0 until 1 is hit, and then slots it into row 1.

The percent
It’s bizarre as it just steadily climbs to 0.45 from 0, 0.05 at a time.

But when printed shows as 0,1,2,3,4 ??? as its dealing with integers again it should all come back as 0 no?

I guess I can’t see the relation between my terrible maths and how unreal interprets percent compared to division.

0 % of 5 is 0.05, 1% is 0.1, 2% is 0.15, 3% is 0.2, 4% is 0.25, 5% is 0.3 etc.
If the decimals are equally ignored, even then it doesn’t make sense,

this rounds to 0array input=0 output. Makes sense
1 array input = 1 output. Makes sense.
2 array input = 1.5 output? wuh unreal reads as 2?!
3 array input = 2 output unreal reads as 3?!
4 array input = 2.5? wot in tarnation reads as 4?

All the items are in the correct order, so it can’t thatch them.
Etc

And if the division and % numbers don’t match, it causes all manner of issues.

Yikes, I need to shower on this.

Any help understanding how it works the maths out or where I’m going wrong would be great.

Alright, so those are two different types of division operations as indicated by different symbols. And they’re both integer-based operations and so we’re not going to get any decimal points in our results.

So the division on top is the normal division operation we’re used to, except it returns only integer values like 0,1,2, etc. So from 0 to 4, it returns 0 as the quotient which means the first 5 elements will be in row 0. From 5 to 9, it returns 1 as the quotient which means the next 5 elements go into row 1.

Now the second division operation % is called a modulo and it returns only the remainder of the division operation. So 0%5 = 0, 1%5= 1, etc. So these will match the column index.

1 Like

Ohhhhhh right,

wow, I was absolutely barking up the entirely wrong tree.

That’s interesting. Thank you for taking the time to explain it, I’ll be able to understand and google further into this.

That’s pretty neat lil doo hicky.

Thanks for helping.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.