Help with an input problem

Godot Version

4.4.stable

Question

I’m wondering if someone can help. I’m looking for an input method for a ui that does something once when a CheckButton is pressed.
I currently have this, but in only works as long as the mouse is moving on the screen after the button has been pressed. I’m sure I’m missing something simple here.

func _input(event: InputEvent) -> void:
	if switch: # this is the CheckButton
		camera_a.make_current() # this is a camera
	else:
		camera_b.make_current() # this is a camera

Do you mean to connect to the button’s toggled signal? That could create a function that switches between cameras

func _on_button_toggled(toggled_on: bool) -> void:
    if toggled_on:
        camera_a.make_current()
    else:
        camera_b.make_current()
1 Like

Thanks! This works:

func _ready() -> void:
        # connect to signal
	switch.toggled.connect(_on_button_toggled)
	
func _on_button_toggled(toggled_on: bool) -> void:
	if toggled_on:
		camera_a.make_current()
	else:
		camera_b.make_current()