Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | mburkard |
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?