0
votes

I have an NSOutlineView subclass that implements the NSSpringLoadingDestination.

The outline view is populated with NSTableCellViews. Each table cell view has an NSTextField and NSImageView. It looks just like the name column in the Finder window: icon and text.

When I drag a row over the text field in another row everything works fine. When the cursor goes over the NSImageView, however, the spring loading exits.

The outline view also loses the highlight for that row.

If I replace the image view with an NSButton containing the image, the spring loading does not exit. And the outline view maintains the highlight.

Can anyone tell me why an NSControl does not interrupt the spring loading but an NSImageView does?

I have tried overriding some different NSView methods but I can’t get the image view to behave like the button.

Thanks.

1
Is the image view editable? What is on the drag pasteboard? NSImageView can accept dragged images, NSButton can't.Willeke
isEditable = false, allowCutCopyPaste = false but that does not change anything. I also tried subclassing NSImageView and implementing NSSpringLoadingDestination returning .disabled in springLoadingEntered(:) but that didn’t work. Then I tried overriding hitTest(:) returning nil but no luck either. This is what I don’t understand: if I use an NSButton instead of an NSImageView, the problem goes away. But if the isSpringLoaded = false, it has the same problem as the image view. I’m just wondering what that property does to disable spring loading that I can’t seem to do in the image view.user5892643
I tried this and a springloaded button has the same problem as the image view and a not springloaded button doesn't. Are you sure about isSpringLoaded = false?Willeke
Sorry, I should have been clearer. When the button isSpringLoaded = false, the spring loading does not exit while dragging over it. It works the opposite of NSImageView. When isSpringLoaded = true, the button works just like the image view. Dragging over it exits spring loading. And the picture becomes like a little dragging dead zone in the outline view. I’ve noticed the same thing in XCode. In the Project Navigator, if you try to drag a file over the icon of a closed folder, nothing happens. You need to put the cursor over the text to activate spring loading.user5892643

1 Answers

1
votes

Even when an image view is uneditable it apparently still handles drag & drop. To fix this call the image view's unregisterDraggedTypes method.