public static int RemoveAllItems(DragDropTarget target, bool sendCallback = true) { var items = target.GetAllAttachedItems(); DragDropEventData eventData = new DragDropEventData(!sendCallback); eventData.Reset(); eventData.target = target; for (int count = items.Count, i = count - 1; i >= 0; --i) { DragDropItem item = items[i]; eventData.item = item; target.OnItemDetach(eventData); item.OnItemDetach(eventData); item.OnSetFree(eventData); } return(items.Count); }
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); }
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); } }
public static bool TryRemoveItem(DragDropItem item, DragDropTarget target, bool sendCallback = true) { if (item == null || target == null) { return(false); } if (item.attachedTarget == target && target.HasItemAttached(item)) { DragDropEventData eventData = new DragDropEventData(!sendCallback); eventData.Reset(); eventData.target = target; eventData.item = item; target.OnItemDetach(eventData); item.OnItemDetach(eventData); item.OnSetFree(eventData); return(true); } else { return(false); } }