You could try it with a signal.
At the top of the script you declare the signal:
Then you emit the signal:
if event is InputEventMouseButton:
if (event.is_pressed() and event.button_index == BUTTON_LEFT):
# start dragging
dragPosition = get_global_mouse_position() - rect_global_position
# end dragging
dragPosition = null
May you will have to emit
dragPositioninstead of rect_global position - that you have to test, I am always unsure with these.
However on your Parent Panel you can now connect the signal dragging. For that you have to click on your button and then Node where you will find your signal. Connect it and in the resulting function you could write:
rect_global_position = position
Another possibility to implement this is with
On your button script you just decalte another variable:
var button_parent : Control = get_parent()
Then you could use
button_parent.rect_global_position = rect_global_position
Personally I always try to avoid
get_parent()because it can easily screw up entire scipts when you have to move scenes inside a node.
Hope that helps