I first tried to look if inside the inspector there is a flag for that (like for making it unresizable) but I did not find anything.
So then I tried doing something like this:
func _input(event): if event is InputEventMouseButton: return (pseudo-code)
hoping that it would “consume” the event and it wouldn’t be processed from the GUI, but no luck.
Then I tried doing func _process: if start_pos != pos: pos = start_pos (pseudo-code)
but once I wanted to have window’s position not absolute (to have it in center of the screen in fullscreen and windowed mode) it snapped it back to the windowed start_pos (even when starting with fullscreen mode from settings) so it wasn’t viable
Searching the subreddit and forum I did not find anything too, except one that said to use Control node instead
So does anybody knows a way to do this?
Thank you everybody in advance (sorry for my english)
You could make it not resizable and have a position variable. Using the second piece of code, you can keep the window’s position at the position variable’s location. Then you can use this code to set the variable to the center of the screen:
@onready var window = $Window #The location of the window node in the scene tree
var position = Vector2(0, 0) #Set to a default value
func _process(_delta:float) -> void:
position = get_window().size / 2.0 #get the window that the node running this code is in and find the center of it
#You can replace the window variable with a reference to the window node, or just change the variable
if not position == window.position:
#You don't even need the if, although it *might* make it a little faster.
#It could also make it a little slower though
window.position = position
NOTE: This code is untested. Use at your own risk.