TextureButtons created with script not working when scene imported to another.

Godot Version

4.2.2

Question

I have created a grid UI screen which is generated programmatically depending on an image I feed into it. The image is broken into TextureButton nodes which make up portions of the grid. I can move and select buttons with keyboard when I test this grid in the immediate scene…

However, when I bring this into my game scene the buttons are no longer working. What is stranger is that if I manually create a grid of TextureButtons this one works when I bring into my game scene. This leads me to believe I am missing a line or two of code when I am creating my grid of buttons.

My grid of buttons is created by a loop and below are the methods used to configure each tile(button). I have excluded a lot of other logic code used to assemble the grid which is not relevant to my problem.

Blockquote
var texbutton = TextureButton.new()
texbutton.set_name()
texbutton.set_focus_mode()
gridcontainer.add_child()
texbutton.set_texture_normal()
texbutton.set_texture_focused()
texbutton.set_focus_neighbor()

func _ready():
get_node(‘Control/GridContainer/tile_1’).grab_focus()

Blockquote

gridcontainer.add_child()

This line isn’t giving you a “Too Few Arguments” error?
add_child documentation

When posting code in this forum, there is a button on the toolbar that looks like this </>. Use that to post code and keep its formatting.

Yes I have an argument in my code but not in what I shared here. To reiterate everything works perfectly when I work with the UI grid in an isolated scene. It’s only when I import it to my game scene that the keyboard response breaks.

If you post code that isn’t code you are using, you are asking people to guess what is wrong with your program.
The chances of anyone guessing correctly are slim to none.

Sure I understand. I guess I was hoping for someone to see what function I’m using to create my texture button and note that I was missing a specific function required.

I’m on holiday right now so I’ll post another thread with all the code when I return.

Thank you