From 1e4841dc522585904d0b1564ddbda5fe913e890e Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 22 Mar 2015 12:52:47 -0300 Subject: drag & drop demo (GUI) --- demos/gui/drag_and_drop/drag_and_drop.scn | Bin 0 -> 2596 bytes demos/gui/drag_and_drop/drag_drop_script.gd | 27 +++++++++++++++++++++++++++ demos/gui/drag_and_drop/engine.cfg | 4 ++++ 3 files changed, 31 insertions(+) create mode 100644 demos/gui/drag_and_drop/drag_and_drop.scn create mode 100644 demos/gui/drag_and_drop/drag_drop_script.gd create mode 100644 demos/gui/drag_and_drop/engine.cfg (limited to 'demos') diff --git a/demos/gui/drag_and_drop/drag_and_drop.scn b/demos/gui/drag_and_drop/drag_and_drop.scn new file mode 100644 index 0000000000..f2122a459e Binary files /dev/null and b/demos/gui/drag_and_drop/drag_and_drop.scn differ diff --git a/demos/gui/drag_and_drop/drag_drop_script.gd b/demos/gui/drag_and_drop/drag_drop_script.gd new file mode 100644 index 0000000000..a99b963efa --- /dev/null +++ b/demos/gui/drag_and_drop/drag_drop_script.gd @@ -0,0 +1,27 @@ + +extends ColorPickerButton + +# member variables here, example: +# var a=2 +# var b="textvar" +func get_drag_data(pos): + + #use another control as drag preview + var cpb = ColorPickerButton.new() + cpb.set_color( get_color() ) + cpb.set_size(Vector2(50,50)) + set_drag_preview(cpb) + #return color as drag data + return get_color() + +func can_drop_data(pos, data): + return typeof(data)==TYPE_COLOR + +func drop_data(pos, data): + set_color(data) + +func _ready(): + # Initialization here + pass + + diff --git a/demos/gui/drag_and_drop/engine.cfg b/demos/gui/drag_and_drop/engine.cfg new file mode 100644 index 0000000000..448939c61d --- /dev/null +++ b/demos/gui/drag_and_drop/engine.cfg @@ -0,0 +1,4 @@ +[application] + +name="Drag & Drop (GUI)" +main_scene="res://drag_and_drop.scn" -- cgit v1.2.3