Focus Neighbor on identical nodes in specific group?

I see!

So the code you posted is to first pick out the first row and left-most column, and then I’d use that in the set_neighbor code?

So far I had the attempt of that set up like this:

var next_slot = slot_index + 1
						prev_slot = slot_index - 1
						button.focus_neighbor_top = all_slots[prev_slot].button.get_path()

How would I best use the result in there instead?

I assume you want to assign the focus to prevent neighbor-ing out of the grid container, you could set the neighbor to itself so it doesn’t move past the button

for i in $GridContainer.get_child_count():
    var is_top: bool  = i < $GridContainer.columns
    var is_left: bool = (i % $GridContainer.columns) == 0
    var child: Control = $GridContainer.get_child(i)

    if is_top:
        child.focus_neighbor_top = child.get_path()
    if is_left:
        child.focus_neighbor_left = child.get_path()

Hmm unfortunately that doesn’t seem to work, it still moves out both top and left.

Wait - staring at this, I realised that I forgot that I have to go one step deeper in the code to fetch the button of my child node. Now it works perfectly!

Thank you so much! This is so much more simple and elegant than what I was trying to do.

And also thanks for being patient with me!