0 votes

I have a toggle fullscreen button, the button has an icon that switches depending on whether the screen is fullscreen or not.

func _button_pressed() -> void:
    OS.window_fullscreen = !OS.window_fullscreen
    icon = _fullscreen_exit_icon if OS.window_fullscreen else _fullscreen_icon

My problem is that there can be other ways to exit fullscreen, for example, when this runs in a browser the user can hit escape to exit fullscreen. When this happens the fullscreen button will have the wrong icon.

I can constantly update the icon with:

func _process(_delta) -> void:
    icon = _fullscreen_exit_icon if OS.window_fullscreen else _fullscreen_icon

But it seems very inefficient to be doing this up to 60 times per second every second when it's not needed 99.99% of the time.

Is there a way I can listen for a change in OS.window_fullscreen instead of constantly polling it?

Godot version 3.2.2
in Engine by (63 points)

1 Answer

+3 votes
Best answer

The viewport has a size_changed() signal that might work for your needs...


by (16,634 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.