How-To: Drag & Drop
Goal: drag an item from one widget and drop it on another, carrying a typed UObject payload.
Prerequisites
Source and target widgets. Drag-drop uses the standard UMG overrides (
OnMouseButtonDown / OnDragDetected / OnDrop); CrimsonUI supplies the operation class.1. Create the operation on drag
In the source widget, override On Drag Detected: Create Drag Drop Operation (Class = Crimson Drag Drop Operation) -> Set Payload Object (Payload = the item UObject) -> set the operation's Default Drag Visual -> return the operation.
2. Read the payload on drop
In the target widget, override On Drop: Cast To CrimsonDragDropOperation -> Get Payload Object -> Cast To your item class -> accept the item. Return true when handled.
Typed subclasses
Domain plugins subclass
UCrimsonDragDropOperation and add strongly-typed properties (CrimsonCore's inventory does exactly this). SetPayloadObject / GetPayloadObject are both Blueprint-callable; GetPayload<T>() is the C++ typed shortcut.Verify
Dragging shows your drag visual; dropping on the target delivers the exact UObject you set; dropping elsewhere cancels harmlessly.
See also
- How-To: Lists with Mixed Item Types - the entries you usually drag.