1
0
Fork 0

Use _gui_input for header drag

Before this, if you moved a window's header to overlap the game window's
header, dragging the window again would drag the window and the game
window.
This commit is contained in:
under 2024-03-20 11:11:16 -07:00
parent 6c7bb284ff
commit 8c8fc8058d
1 changed files with 8 additions and 5 deletions

View File

@ -38,6 +38,14 @@ func getwinmosposi() -> Vector2i:
return DisplayServer.window_get_position() + Vector2i(floori(mospos.x), floori(mospos.y)) return DisplayServer.window_get_position() + Vector2i(floori(mospos.x), floori(mospos.y))
func _input(event: InputEvent): func _input(event: InputEvent):
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT:
if event.is_released():
dragging = false
elif dragging and event is InputEventMouseMotion:
DisplayServer.window_set_position(begwinpos + getwinmosposi() - begwinmosposi)
func _gui_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.double_click:
@ -51,11 +59,6 @@ func _input(event: InputEvent):
dragging = true dragging = true
begwinmosposi = getwinmosposi() begwinmosposi = getwinmosposi()
begwinpos = DisplayServer.window_get_position() begwinpos = DisplayServer.window_get_position()
elif event.is_released():
dragging = false
elif dragging and event is InputEventMouseMotion:
DisplayServer.window_set_position(begwinpos + getwinmosposi() - begwinmosposi)
" "
[sub_resource type="GDScript" id="GDScript_2514r"] [sub_resource type="GDScript" id="GDScript_2514r"]