Can't drag to full line NSOutlineView

I have an NSOutlineView in which Ive implemented Drag and Drop, its values ​​are filled using bindings.

Everything works for the logic I want, and it's basically the ability to drop only root level intermediate elements, and children are not allowed to drag or drop anywhere. So I'm just trying to reorder if you do.

My problem comes into play with where in the NSOutlineView is taking blobs. It looks like it only lets me fall to the left side of the row. I don't seem to be running anywhere. My lines are view based and have an image view.

This one is working This shows that it works

Here is it not working. This does not work.

Here is my code for acceptDrop.

- (NSDragOperation)outlineView:(NSOutlineView *)ov validateDrop:(id < NSDraggingInfo >)info proposedItem:(id)item proposedChildIndex:(NSInteger)childIndex {

    // Check to see what we are proposed to be dropping on
    NSTreeNode *targetNode = item;
    // A target of "nil" means we are on the main root tree
    if (targetNode == nil) {
        //If were dropping on the physical item lets say no
       if (childIndex == NSOutlineViewDropOnItemIndex) {
            return NSDragOperationNone;
       }
       //otherwise we are in-between so lets return move.
       return NSDragOperationMove;
    } else {
        return NSDragOperationNone;
    }
}

      

Is it possible it has something to do with my view setting instead of my NSOutlineView code?

UPDATE

It works on the very top line no matter where my cursor is, but only on the far left for all other lines.

+3


source to share


1 answer


This has been fixed.



NSUInteger maxNumberOfRows = [[_hostController arrangedObjects] count];
// Check to see what we are proposed to be dropping on
NSTreeNode *targetNode = item;
// A target of "nil" means we are on the main root tree
if (targetNode == nil) {
    //If were dropping on the physical item lets say no
    if (childIndex == NSOutlineViewDropOnItemIndex) {
        [ov setDropItem:nil dropChildIndex:maxNumberOfRows];
        return NSDragOperationMove;
    }
    [ov setDropItem:nil dropChildIndex:childIndex];
    return NSDragOperationMove;
} else {
    //If its not a host we dont want to allow drop
    if (![self isHost:[item representedObject]]) {
        return NSDragOperationNone;
    }
    if (childIndex == NSOutlineViewDropOnItemIndex) {
        [ov setDropItem:nil dropChildIndex: [ov rowForItem:item]];
        return NSDragOperationMove;
    }
    return NSDragOperationNone;
}

      

0


source







All Articles