Questions tagged [nsdraggingitem]

The NSDraggingItem class encompasses a single dragged item within an NSDraggingSession instance.

The NSDraggingItem class encompasses a single dragged item within an NSDraggingSession instance.

See NSDraggingSession Class Reference for more information

NSDraggingItem objects have extremely limited lifetimes. Do not retain these items as changing outside of the prescribed lifetimes have no impact on the drag.

When the NSDraggingSession method beginDraggingSessionWithItems:event:source: is called, the dragging items passed to the method are consumed immediately and are not retained. Any further changes to the dragging item associated with the returned NSDraggingSession must be done via the enumeration method enumerateDraggingItemsWithOptions:forView:classes:searchOptions:usingBlock:. When enumerating, NSDraggingItem instances are created right before being given to the enumeration Block. After returning from the Block, the NSDraggingItem instance is no longer valid.

Home Page: https://developer.apple.com/library/mac/documentation/AppKit/Reference/NSDraggingItem_Class/Reference/Reference.html

7 questions
8
votes
4 answers

How do you change a drag-and-dropped image mid-drag?

So I want to drag an object from one source to multiple potential destinations. When the object is over each destination, I want it to 'morph' into a different image. Is there a straightforward way to do this from the NSDragSource perspective?
Ben Gottlieb
  • 85,404
  • 22
  • 176
  • 172
5
votes
1 answer

Avoid blocking the main thread in a NSDraggingSession using a NSPasteboardItemDataProvider

In a Mac OS X app (Cocoa), I'm copying some images from my app to others using a NSDraggingSession. The NSDraggingItem makes use of an object that implements the protocol NSPasteboardItemDataProvider, to provide the data when the user drops it. As…
Daniel
  • 683
  • 1
  • 9
  • 20
4
votes
2 answers

NSOutlineView drag image

I want to change the image used when I drag an item from a view- and datasource-based NSOutlineView, but can't seem to find a hook. I've tried modifying - (void)dragImage:(NSImage *)anImage at:(NSPoint)viewLocation offset:(NSSize)initialOffset…
1
vote
0 answers

Want dragging left its item where it is while dragging

I made custom dragging image and currently using it. a problem is when I drag items item's origin places become a blank space. I want to left original image(?) where it's origin. So my collection view look like nothing happened. (Of course, there…
WoffOVkee
  • 435
  • 3
  • 16
1
vote
1 answer

NSDragOperation for drag vom NSTableView is -1

Simple setup: I've got an NSTableView that allows items to be dragged to an NSView subclass. In the view I'm checking the drag operation via NSDraggingInfo's method draggingSourceOperationMask. Drops received there have a NSDragOperation of -1.…
ATV
  • 4,116
  • 3
  • 23
  • 42
0
votes
0 answers

Snapping (constraining drag item's position) during NSDraggingSession

I am looking for a way how to constrain the NSDraggingItem position during dragging. I first checked if the enumerateDraggingItemsWithOptions: method could help. I tried to set the draggingFrame of each enumerated item to (my) snap position. It…
0
votes
1 answer

NSPasteboard Copy Dragged and Dropped File

Although I have working code, I'm confused about whether I'm taking the right approach to NSPasteboard and I am reaching out to see if anyone can help me clarify the best approach. There doesn't appear to be any full documentation written by Apple…
sketchyTech
  • 5,746
  • 1
  • 33
  • 56