Append signal source by code

Godot Version

4.51

Question

Hey I just noticed that there is an ‘Append Source’ option in the connect signal menu and was wondering if there is anyway of doing that via code?

You can just Callable.bind() any argument you want when connecting the signal in code.

Example:

extends Node


@onready var button: Button = $Button


func _ready() -> void:
    button.pressed.connect(_on_button_pressed.bind("I've been pressed", button))
    
    
func _on_button_pressed(message: String, button: Button) -> void:
    prints(message, button.name)
1 Like

Super! Thank you!