How to enable fullscreen

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By TheVorkMan_

Hello everyone!
Today I try enable fullscreen, but its not working.
I make this code:

extends TextureButton
func _fullscreen(button_pressed):
	if button_pressed == true:
		DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN, 3)
	if button_pressed == false:
		DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED, 0)
	print("test")

But I get this error when try enable fullscreen:

	E 0:00:02:0821   switch_button.gd:14 @ _fullscreen(): Condition "!windows.has(p_window)" is true.
	<Source code C++>platform/windows/display_server_windows.cpp:1320 @ window_set_mode()
	<Stack trace>switch_button.gd:14 @ _fullscreen()

Help me please!

switch_button.gd:14 where is this?

Moreus | 2023-04-15 08:26

Its button that enables and disables fullscreen

TheVorkMan_ | 2023-04-15 08:30

Trying change code to switch full screen with input keys, and share effect

Moreus | 2023-04-15 08:57

:bust_in_silhouette: Reply From: TheVorkMan_

Ok, I resolved this problem

extends TextureButton
func _fullscreen(button_pressed):
	if button_pressed == true:
		DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
	if button_pressed == false:
		DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)