Godot Version
Godot 4.3
Question
The problem is described in the topic title.
Is there a way to fix or work around this?
Code
using Godot;
using System;
public partial class Draggable : Node
{
[Export]
public BaseButton zone;
public override void _Ready()
{
zone.FocusMode = Control.FocusModeEnum.None;
zone.Connect(BaseButton.SignalName.ButtonDown, new Callable(this, nameof(OnButtonDown)));
zone.Connect(BaseButton.SignalName.ButtonUp, new Callable(this, nameof(OnButtonUp)));
}
public void OnButtonDown()
{
GD.Print("ButtonDown");
//This part changes parent
Node zoneContainer = zone.GetParent();
zoneContainer.RemoveChild(zone);
zoneContainer.AddChild(zone);
}
public void OnButtonUp()
{
GD.Print("ButtonUp");
}
}
Result:
If I don’t change the parent the ButtonUp event will happen.