问题
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