コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 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);
     }
 }
コード例 #4
0
        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);
            }
        }