LShi
LShi

Reputation: 1502

NSOutlineView doesn't display the blue guide/separator when dragging-in

I have implemented the drag & drop feature for an NSOutlineView. I can drag-in new items into it and also reorder the items. However, there's a strange behaviour:

If one or more items have been reordered (by dragging & dropping), when a new item is dragged in, the NSOutlineView doesn't show the usual "blue separator line" between two rows (where it may accept the drop). Instead, a gap is opened with the same animation as that of a local reordering.

If no item has been reordered, the blue line shows as usual.

The NSOutlineView is populated solely with an NSOutlineViewDataSource. It's just been migrated from a "cocoa binding"(with NSTreeController) set-up which worked without this issue.

Upvotes: 1

Views: 539

Answers (1)

LShi
LShi

Reputation: 1502

This NSTableViewDraggingDestinationFeedbackStyle controls the separation behaviour.

I accidentally commented out the line outlineView.draggingDestinationFeedbackStyle = .sourceList

func outlineView(_ outlineView: NSOutlineView,
                 draggingSession session: NSDraggingSession,
                 willBeginAt screenPoint: NSPoint,
                 forItems draggedItems: [Any])
{
    outlineView.draggingDestinationFeedbackStyle = .gap
}

func outlineView(
        _ outlineView: NSOutlineView,
        draggingSession session: NSDraggingSession,
        endedAt screenPoint: NSPoint,
        operation: NSDragOperation)
    {
        outlineView.draggingDestinationFeedbackStyle = .sourceList
    }

Upvotes: 2

Related Questions