29 lines
557 B
GDScript
29 lines
557 B
GDScript
extends Control
|
|
|
|
|
|
var dragging = false
|
|
var dragging_start_position = Vector2i()
|
|
|
|
@onready var window: Window = $".."
|
|
|
|
|
|
func _ready():
|
|
set_process_input(true)
|
|
|
|
|
|
func _input(event):
|
|
if event is not InputEventMouseButton:
|
|
return
|
|
if event.button_index != MOUSE_BUTTON_LEFT:
|
|
return
|
|
|
|
if event.pressed:
|
|
dragging = true
|
|
dragging_start_position = Vector2i(get_global_mouse_position())
|
|
else:
|
|
dragging = false
|
|
|
|
|
|
func _process(_delta):
|
|
if dragging:
|
|
window.position = window.position + Vector2i(get_global_mouse_position()) - dragging_start_position
|