NSOutlineView spring load expanded item

拈花ヽ惹草 提交于 2019-12-24 21:23:40

问题


I have a subclass of NSOutlineView implementing the NSSpringLoadingDestination protocol.

Everything works great. The only issue is when I try to drag an item over an already expanded item, spring loading never activates.

The NSOutlineViewDelegateProtocol method outlineView(_:shouldExpandItem:) returns true.

The method outlineView(_:validateDrop:proposedItem:proposedChildIndex:) returns a valid NSDragOperation. The expanded item becomes highlighted when I drag over it.

And the NSSpringLoadingDestination method springLoadingUpdated(_:) returns .enabled

But springLoadingActivated(_:draggingInfo:) is never called.

Oddly, if I do something in springLoadingUpdated(:) like test isItemExpanded(:) and immediately close it, spring loading activates as expected. But that's not a solution.

Any insights would be greatly appreciated.

Thanks in advance.


回答1:


I was able to get a NSOutlineView that is a NSSpringLoadingDestination to correctly call springLoadingActivated(_:draggingInfo:) by overriding the NSOutlineView function isExpandable to return true.

override func isExpandable(_ item: Any?) -> Bool { return true }



来源:https://stackoverflow.com/questions/48174641/nsoutlineview-spring-load-expanded-item

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!