Skip to content

Commit cb4c9e5

Browse files
committed
fix: stop drag-drop from reparenting item icons
Fixes #2793 Prevent Gwen's default drop handler from reparenting the dragged icon into the hovered control, which could place the icon into the wrong slot/container. Draggable now forwards DragAndDrop_HandleDrop to its SlotItem parent, and the drag package stores the source SlotItem in Package.UserData to make slot handlers deterministic.
1 parent bc83400 commit cb4c9e5

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Intersect.Client.Core/Interface/Game/Draggable.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public override bool DragAndDrop_Draggable()
1616

1717
public override bool DragAndDrop_CanAcceptPackage(Package package)
1818
{
19+
// Important: Icon is the topmost hovered control, so it must be allowed to "receive" the drop, BUT: we forward handling to SlotItem.
1920
return true;
2021
}
2122

@@ -27,6 +28,7 @@ public override bool DragAndDrop_CanAcceptPackage(Package package)
2728
DrawControl = this,
2829
Name = Name,
2930
HoldOffset = ToLocal(InputHandler.MousePosition.X, InputHandler.MousePosition.Y),
31+
UserData = Parent, // Expected to be SlotItem (InventoryItem/BankItem/etc)
3032
};
3133
}
3234

@@ -39,4 +41,22 @@ public override void DragAndDrop_EndDragging(bool success, int x, int y)
3941
{
4042
IsVisibleInParent = true;
4143
}
44+
45+
public override bool DragAndDrop_HandleDrop(Package package, int x, int y)
46+
{
47+
// Never allow Base.DragAndDrop_HandleDrop() to run on the icon because it reparents SourceControl (Base.cs)
48+
// Forward drop handling to the slot (or nearest SlotItem ancestor).
49+
var node = Parent;
50+
while (node != null)
51+
{
52+
if (node is SlotItem)
53+
{
54+
return node.DragAndDrop_HandleDrop(package, x, y);
55+
}
56+
57+
node = node.Parent;
58+
}
59+
60+
return false;
61+
}
4262
}

0 commit comments

Comments
 (0)