Any idea what the "screen_resized" signal is called in Godot 4?

The following works fine in Godot 3.5.x:
var screen_resized_signal = get_tree().connect("screen_resized", self, "_on_screen_resized")

Here it is adapted for what I think is the correct Godot 4 syntax:
var screen_resized_signal = get_tree().connect("screen_resized", _on_screen_resized)

Godot 4 throws a "nonexistant signal" error for "screen_resized".
Any ideas? Thanks

  • The new signal is called "size_changed" but it is a property of the Viewport. So get the root Viewport first to attach that signal.

The new signal is called "size_changed" but it is a property of the Viewport. So get the root Viewport first to attach that signal.

    21 days later

    zapposh

    If it's alright with you, can you share your working code? I tried connecting the "size_changed" signal but it doesn't work. I'm probably missing something because I'm very new to Godot.

    Here's my current code for the main scene's Node:

    extends Node
    
    var root: Viewport
    
    func _ready():
    	print("Getting ready...")
    	root = get_tree().get_root()
    	root.connect("size_changed", _on_size_changed)
    
    func _process(delta):
    	pass
    
    func _on_size_changed():
    	print("Resizing window")

    I tried resizing my window, but I can't get it to print.

    9 months later