Godot Version
4.6.1
Question
I’m trying to make some logic apply to all button nodes in an array without having to type out each node each time for one big of logic. The code below works for what I want it to do, but I don’t want it to be new logic each time I put a new button in the scene for what is essentially doing the same thing each time. What i’ve been trying to do is for it to take whatever button I am currently hovering over, tell me that node’s index on the array, and make the new index that button’s index, as well as releasing that button’s focus. I’ve been bashing my head against a wall for like a day now and can’t figure it out though. Any help is appreciated, even just telling me my method sucks.
if NGButton.is_hovered() && last_mouse_pos != current_mouse_pos:
index = 0
NGButton.release_focus()
if CNTButton.is_hovered() && last_mouse_pos != current_mouse_pos:
index = 1
CNTButton.release_focus()