Skip to content

Draggable Nodes

Valk edited this page Sep 22, 2024 · 12 revisions

Simply add the [Draggable] attribute to any Node2D or Control node and it will become draggable in-game.

The attribute has 2 params you can specify. For example [Draggable(DragType.Hold, DragConstraints.Vertical)]

To do something when the dragged node has been released hook into the Draggable.DragReleased event. For example

Draggable.DragReleased += node =>
{
    if (node is Player player)
    {
        player.QueueFree();
    }
}
Clone this wiki locally