简体   繁体   English

拖入时,NSOutlineView不显示蓝色参考线/分隔符

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

I have implemented the drag & drop feature for an NSOutlineView . 我已经为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). 如果已对一个或多个项目进行了重新排序 (通过拖放),则在将新项目拖放到其中时, NSOutlineView 不会在两行之间显示通常的“蓝色分隔线” (可以接受放置)。 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 . NSOutlineView仅使用NSOutlineViewDataSource填充。 It's just been migrated from a "cocoa binding"(with NSTreeController ) set-up which worked without this issue. 它只是从“可可绑定”(带有NSTreeController )设置迁移而来的,没有出现此问题。

This NSTableViewDraggingDestinationFeedbackStyle controls the separation behaviour. NSTableViewDraggingDestinationFeedbackStyle控制分离行为。

I accidentally commented out the line outlineView.draggingDestinationFeedbackStyle = .sourceList 我不小心outlineView.draggingDestinationFeedbackStyle = .sourceList一行注释为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
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM