Godot Version
v4.5.1.stable.mono.official [f62fdbde1]
Question
Hello everyone, I’ve been meaning to set up a system to drag-n-drop buttons around into slots.
Basically, I have two components:
ButtonItem(extendsButton) are nodes that can be both clicked and dragged/droppedButtonSlot(extendsControl) are nodes that are supposed to contain aButtonItem
ButtonItem is the parent class of all my custom button-related nodes. In my project (an incremental game), those buttons are at the core of the gameplay.
ButtonSlot is the class for the button’s slots. ButtonItems can be moved from slots to slots.
Anyway, the ButtonItems can be successfully dragged from one ButtonSlot to another, but when dragging them, it triggers their pressed signal. How can I prevent this?
I also tried this solution before :
# button_item.gd
var dragging := false
func _ready():
# I wanted to make it so that only when the click was released, the button's
# behavior would run. The actual press trigger would only be used to drag the
# node around.
action_mode = BaseButton.ACTION_MODE_BUTTON_RELEASE
button_up.connect(_on_pressed)
# ...
func _on_pressed():
# if the button is being dragged, skip the behavior
if dragging:
return
# ...
func _get_drag_data(_at_position):
dragging = true
# ...
It turned out to not do anything. I must be missing something. I’d really appreciate it if someone could help me with that! Thanks ![]()
(Apologies for bad english, it’s not my first language)