Godot Version
4.3
Question
If you create a Scene in the Editor, you can visually connect to methods in your script. When you open the corresponding .tscn file in a text editor, you can find those saved connections at the end of the file like for example:
[connection signal="focus_entered" from="." to="." method="_on_focus_entered"]
[connection signal="focus_exited" from="." to="." method="_on_focus_exited"]
Unfortunately, I can’t quite figure out how to do this programatically.
var a = Control.new()
var b = Control.new()
a.add_child(b)
b.focus_entered.connect(a.grab_focus) # Just connect some random
b.owner = a # method for test purposes
var file = PackedScene.new()
file.pack(a)
ResourceSaver.save(file, "res://test.tscn" )
This does not save the connections. I added this little example to bring my point across, but I’ve also tried creating custom classes with custom signals. I can’t @export the signals though, so that doesn’t work either.
Any help would be appreciated.