public static int RemoveAllItems(DragDropTarget target) { var items = target.GetAllAttachedItems(); DragDropEventData eventData = new DragDropEventData(); eventData.Reset(); eventData.external = true; eventData.target = target; foreach (var item in items) { eventData.item = item; target.OnItemDetach(eventData); item.OnItemDetach(eventData); target.OnItemExit(eventData); item.OnItemExit(eventData); item.OnSetFree(eventData); } return(items.Length); }
void ReplaceDropTarget(DragDropTarget oldTarget, DragDropTarget newTarget) { if (oldTarget == newTarget) { return; } if (oldTarget) { oldTarget.OnItemExit(DragDropEventData.current); OnItemExit(DragDropEventData.current); } DragDropEventData.current.target = newTarget; if (newTarget) { newTarget.OnItemEnter(DragDropEventData.current); OnItemEnter(DragDropEventData.current); } }
public static bool TryRemoveItem(DragDropItem item, DragDropTarget target) { if (item.attachedTarget == target && target.HasItemAttached(item)) { DragDropEventData eventData = new DragDropEventData(); eventData.Reset(); eventData.external = true; eventData.target = target; eventData.item = item; target.OnItemDetach(eventData); item.OnItemDetach(eventData); target.OnItemExit(eventData); item.OnItemExit(eventData); item.OnSetFree(eventData); return(true); } else { return(false); } }