NSDraggingSession distorts the images I give it
I’m modernising some old code that does drag and drop the old, simple and perfectly functional (but deprecated) way.
The new way seems twice as complicated to me, but hey-ho.
Anyway, I’m creating NSDraggingItems for each item to be dragged, and I’m setting the image and frame to sane values. When I start to drag the items however, the images are slightly resized - they expand widthways a small amount, but vertically a somewhat larger amount, making each item appear to stretch vertically. It looks like crap.
The images are actually square - and I set the image size to match the frame size, which has the same width and height.
for( DKOLibraryItem* libItem in itemsToDrag )
NSDraggingItem* dragItem = [[NSDraggingItem alloc] initWithPasteboardWriter:libItem];
NSRect libItemRect = [dv imageRectForItemAtIndex:dragItemIndex]; // this rect is square, width = height
NSImage* icon = [libItem.previewImage copy];
icon.size = libItemRect.size;
[dragItem setDraggingFrame:libItemRect contents:icon];
//…. other stuff
Has anyone some clue what’s going on here?
Here’s a short video showing what I’m seeing. http://s3.amazonaws.com/Mapdiva/Video/Screen%20Recording%202019-11-06%20at%203.40.09%20pm.mov