Godot Version
godot 4.5
Question
how do use code to make simple drag and drop ui that close and open when click on sorry if sound like i want somebody make it for me it just most tutorials i search only show how to add items and not how drag uit of the inventory
i
If you share code, please wrap it inside three backticks or replace the code in the next block:
var dragging = false
var mouse_offset
var dalay = 8
func _physics_process(delta):
if dragging == true:
var tween = get_tree().create_tween()
tween.tween_property(self ,"position", get_global_mouse_position() -mouse_offset , dalay * delta)
func _input(event):
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_RIGHT:
if event.pressed:
if get_rect().has_point(to_local(event.position)):
dragging = true
mouse_offset = event.position - position
elif event.button_index == MOUSE_BUTTON_RIGHT and not event.pressed:
dragging = false
func _on_area_2d_area_entered(area):
queue_free()