29 lines
881 B
GDScript3
29 lines
881 B
GDScript3
|
|
class_name TextBox
|
||
|
|
extends BoxContainer
|
||
|
|
|
||
|
|
@onready var dragger = $Dragger
|
||
|
|
|
||
|
|
func _ready():
|
||
|
|
dragger.mouse_filter = Control.MOUSE_FILTER_STOP
|
||
|
|
dragger.connect("gui_input", _on_dragger_input)
|
||
|
|
|
||
|
|
func _on_dragger_input(event: InputEvent) -> void:
|
||
|
|
if event is InputEventScreenTouch and event.pressed:
|
||
|
|
if event.pressed:
|
||
|
|
self.set_drag_preview(self.duplicate())
|
||
|
|
get_viewport().gui_force_drag(self)
|
||
|
|
|
||
|
|
# Se llama cuando este nodo está siendo arrastrado
|
||
|
|
func _get_drag_data(_position: Vector2) -> Variant:
|
||
|
|
return self
|
||
|
|
|
||
|
|
# Se llama en los hermanos cuando se arrastra sobre ellos
|
||
|
|
func _can_drop_data(_position: Vector2, data: Variant) -> bool:
|
||
|
|
return data is TextBox
|
||
|
|
|
||
|
|
# Se llama cuando se suelta el nodo sobre otro
|
||
|
|
func _drop_data(_position: Vector2, data: Variant) -> void:
|
||
|
|
if data.get_parent() == get_parent():
|
||
|
|
var container = get_parent()
|
||
|
|
container.move_child(data, get_index())
|