1
0
Fork 0

Prevent multiple windows from being dragged at the same time

Before this, if the headers of two windows overlapped and you clicked
and dragged in that overlap, both windows would move at the same time.
After this, only the front window gets dragged. The way that this works
is that we use _gui_input instead of _input. This works because
_gui_input is only sent to the top-level control.
This commit is contained in:
under 2024-03-20 11:27:27 -07:00
parent 359e60d108
commit 845a09a62b
1 changed files with 13 additions and 9 deletions

View File

@ -30,15 +30,7 @@ func getmosposi() -> Vector2i:
func _input(event: InputEvent): func _input(event: InputEvent):
if event is InputEventMouseButton: if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT: if event.button_index == MOUSE_BUTTON_LEFT:
if event.double_click: if event.is_released():
if get_global_rect().has_point(get_global_mouse_position()):
window.toggle_maximized()
elif event.pressed:
if get_global_rect().has_point(get_global_mouse_position()):
dragging = true
begmosposi = getmosposi()
begwndpos = window.get_global_rect().position
elif event.is_released():
dragging = false dragging = false
# snap within game window # snap within game window
var rect = window.get_global_rect() var rect = window.get_global_rect()
@ -50,6 +42,18 @@ func _input(event: InputEvent):
elif event is InputEventMouseMotion: elif event is InputEventMouseMotion:
if dragging: if dragging:
window.global_position = begwndpos + getmosposi() - begmosposi window.global_position = begwndpos + getmosposi() - begmosposi
func _gui_input(event: InputEvent):
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT:
if event.double_click:
if get_global_rect().has_point(get_global_mouse_position()):
window.toggle_maximized()
elif event.pressed:
if get_global_rect().has_point(get_global_mouse_position()):
dragging = true
begmosposi = getmosposi()
begwndpos = window.get_global_rect().position
" "
[sub_resource type="GDScript" id="GDScript_fvsxv"] [sub_resource type="GDScript" id="GDScript_fvsxv"]