/// <summary> /// Ends the drag operations, and eventually applies the drag outcome. /// Returns TRUE if the position of the dragged item actually changed. /// Called automatically by Drag method. Use it only if you want to force the end of a drag operation. /// </summary> /// <param name="applyDrag">If TRUE applies the drag results, otherwise simply cancels the drag</param> public static DeDragResult EndDrag(bool applyDrag) { if (_dragData == null) { return(new DeDragResult(DeDragResultType.NoDrag)); } int dragFrom = _dragData.draggedItemIndex; int dragTo = _dragData.currDragIndex > _dragData.draggedItemIndex ? _dragData.currDragIndex - 1 : _dragData.currDragIndex; if (applyDrag) { bool changed = _dragData.currDragIndex <_dragData.draggedItemIndex || _dragData.currDragIndex> _dragData.draggedItemIndex + 1; if (Event.current.type == EventType.Repaint) { Event.current.type = EventType.Used; } else if (Event.current.type == EventType.Used) { ApplyDrag(); } else { _waitingToApplyDrag = true; } DeDragResultType resultType = changed ? DeDragResultType.Accepted : DeDragResultType.Ineffective; return(new DeDragResult(resultType, dragFrom, dragTo)); } Reset(); return(new DeDragResult(DeDragResultType.Canceled, dragFrom, dragTo)); }
public DeDragResult(DeDragResultType outcome, int movedFromIndex = -1, int movedToIndex = -1) { this.outcome = outcome; this.movedFromIndex = movedFromIndex; this.movedToIndex = movedToIndex; }