-1

I'm trying to implement a drag & drop for NSTableCellView look like screenshot, but the only thing i can do just the text, not a whole cell like screenshot bellow :(

enter image description here

Antony Raphel
  • 2,036
  • 2
  • 25
  • 45
Mark G
  • 53
  • 5

2 Answers2

0

Drag and Drop Programming

The Dragged Image

The image that is dragged in a dragging session is simply an image that represents the data on the pasteboard. Although a dragging destination can access the image, its primary concern is with the pasteboard data that the image represents—the dragging operation that a destination ultimately performs is on the pasteboard data, not on the image itself.

See Custom drag image with NSTableView as drag source

Community
  • 1
  • 1
catlan
  • 25,100
  • 8
  • 67
  • 78
0

Here is my answer for my question :)

NSView to NSImage: link

Override draggingImageComponents in NSTableCellView subclass

-(NSArray *) draggingImageComponents{
    self.layer.opacity = 0.5;
    NSImage *image = [self imageRepresentation];
    self.layer.opacity = 1;

    NSDraggingImageComponent *draggingImage = [NSDraggingImageComponent draggingImageComponentWithKey:@"background"];
    draggingImage.contents = image;
    draggingImage.frame = self.bounds;
    return @[draggingImage];
}
Mark G
  • 53
  • 5