properly handle connecting to a box that already has a connection

This commit is contained in:
xxSeys1
2025-06-14 17:20:28 +02:00
parent 2e0c35e6e4
commit 92edb996f2
2 changed files with 12 additions and 13 deletions

View File

@@ -544,15 +544,13 @@ namespace FlaxEditor.Surface.Elements
public override void OnMouseLeave()
{
if (_originalTooltipText != null)
{
TooltipText = _originalTooltipText;
}
if (_isMouseDown)
{
_isMouseDown = false;
if (Surface.CanEdit)
{
if (Input.GetKey(KeyboardKeys.Control))
if (IsOutput && Input.GetKey(KeyboardKeys.Control))
{
List<Box> connectedBoxes = new List<Box>(Connections);
@@ -564,25 +562,21 @@ namespace FlaxEditor.Surface.Elements
}
else if (!IsOutput && HasSingleConnection)
{
var connectedBox = Connections[0];
var otherBox = Connections[0];
if (Surface.Undo != null && Surface.Undo.Enabled)
{
var action = new ConnectBoxesAction((InputBox)this, (OutputBox)connectedBox, false);
BreakConnection(connectedBox);
var action = new ConnectBoxesAction((InputBox)this, (OutputBox)otherBox, false);
BreakConnection(otherBox);
action.End();
Surface.AddBatchedUndoAction(action);
Surface.MarkAsEdited();
}
else
{
BreakConnection(connectedBox);
}
Surface.ConnectingStart(connectedBox);
BreakConnection(otherBox);
Surface.ConnectingStart(otherBox);
}
else
{
Surface.ConnectingStart(this);
}
}
}
base.OnMouseLeave();