drag & drop demo (GUI)
This commit is contained in:
parent
78694d8542
commit
1e4841dc52
BIN
demos/gui/drag_and_drop/drag_and_drop.scn
Normal file
BIN
demos/gui/drag_and_drop/drag_and_drop.scn
Normal file
Binary file not shown.
27
demos/gui/drag_and_drop/drag_drop_script.gd
Normal file
27
demos/gui/drag_and_drop/drag_drop_script.gd
Normal file
@ -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
|
||||||
|
|
||||||
|
|
4
demos/gui/drag_and_drop/engine.cfg
Normal file
4
demos/gui/drag_and_drop/engine.cfg
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[application]
|
||||||
|
|
||||||
|
name="Drag & Drop (GUI)"
|
||||||
|
main_scene="res://drag_and_drop.scn"
|
@ -352,6 +352,7 @@ void ColorPickerButton::set_color(const Color& p_color){
|
|||||||
|
|
||||||
|
|
||||||
picker->set_color(p_color);
|
picker->set_color(p_color);
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
Color ColorPickerButton::get_color() const{
|
Color ColorPickerButton::get_color() const{
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user