Can't set focus on label that's spawned in

Godot Version

4.2

Question

Code with all my attempts below.
Grab_focus doesn’t work. Even after setting focus mode to All. Tried even ignoring my variables that I set and went through the tree based on a hard reference to a parent object and going down through the children, but even that doesn’t work.

Oh yeah. And Follow Focus is on on the scroll container all this is in. Still won’t work.

What is your use case scenario?

How did you determine this? Note that Labels (unlike e.g. Buttons) don’t have visuals that indicate if they have focus by default. They still get focused, nonetheless.

Because the scroll container it’s in that’s set to Follow Focus won’t move to show it.

To anyone experiencing this: I worked around this issue and resolved it for my particular use-case by just hard-coding the scroll container move to the bottom after adding the label to it. Don’t know if I should mark this solved though because it’s a work-around.

Where are you running the code you posted above? If it’s in _ready, try using call_deferred (as advised in the documentation for grab_focus).