【问题标题】:NSOutlineView doesn't display the blue guide/separator when dragging-inNSOutlineView 在拖入时不显示蓝色指南/分隔符
【发布时间】:2017-10-13 11:37:21
【问题描述】:

我已经为NSOutlineView 实现了拖放功能。我可以将新项目拖入其中并重新排序项目。但是,有一个奇怪的行为

如果一个或多个项目被重新排序(通过拖放),当一个新项目被拖入时,NSOutlineView 不显示通常的“蓝色分隔线" 两行之间 (它可以接受下降)。相反,一个间隙被打开,其动画与本地重新排序的动画相同。

如果没有重新订购商品,蓝线将照常显示。

NSOutlineView 仅填充有 NSOutlineViewDataSource。它刚刚从“可可绑定”(带有NSTreeController)设置迁移,该设置没有此问题。

【问题讨论】:

    标签: swift macos cocoa drag-and-drop nsoutlineview


    【解决方案1】:

    这个NSTableViewDraggingDestinationFeedbackStyle 控制分离行为。

    我不小心把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
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-13
      • 1970-01-01
      • 2019-09-25
      • 2014-01-01
      • 2019-01-12
      • 1970-01-01
      相关资源
      最近更新 更多