• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Drag and drop on table view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Drag and drop on table view


  • Subject: Drag and drop on table view
  • From: "J.E. Schotsman" <email@hidden>
  • Date: Fri, 02 Dec 2016 14:06:57 +0100


Hello,

Asking the pundits for help again...

So far I am unsuccesful trying to implement drag & drop .
I want to be able to drag a file or folder on a table view and process the file after that.

On startup I do

jobList.registerForDraggedTypes( [kUTTypeFileURL as String] )
jobList.setDropRow( -1, dropOperation:.On ) // don’t drop on a cell

Handling the drag:

extension NSTableView //MARK: extension dragging
 {
 override public func draggingEntered( sender:NSDraggingInfo ) -> NSDragOperation
  {
  Swift.print("draggingEntered called")

  Swift.print("dragged types = \(sender.draggingPasteboard().types!)")
  if sender.draggingPasteboard().types!.contains( kUTTypeFileURL as String )
   {
   Swift.print("contains kUTTypeFileURL")
   let draggingSourceOperationMask  = sender.draggingSourceOperationMask()
   Swift.print("dragging source operation mask = \(draggingSourceOperationMask)")
   if draggingSourceOperationMask.contains(.Link) { return .Link }
   else if draggingSourceOperationMask.contains(.Generic) { return .Generic }
   }

  Swift.print("should not get here")

  return .None
  }

 override public func performDragOperation( sender:NSDraggingInfo) -> Bool
  {
  Swift.print("performDragOperation called")
  let pasteboard = sender.draggingPasteboard()

  if pasteboard.types!.contains( kUTTypeFileURL as String )
   {
   if let fileURL = NSURL( fromPasteboard:pasteboard )
    {
    // process file
    return true
    }
   }
   return false
  }
 }

When testing this the printout is

draggingEntered called
dragged types = ["public.file-url", "CorePasteboardFlavorType 0x6675726C", "dyn.ah62d4rv4gu8y6y4grf0gn5xbrzw1gydcr7u1e3cytf2gn", "NSFilenamesPboardType", "dyn.ah62d4rv4gu8yc6durvwwaznwmuuha2pxsvw0e55bsmwca7d3sbwu", "Apple URL pasteboard type", "com.apple.finder.node"]
contains kUTTypeFileURL
dragging source operation mask = NSDragOperation(rawValue: 55)

So the performDragOperation method is not called.
I have a feeling that the code belongs in the delegate but I cannot find any info on this.

Any help appreciated

Jan E.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Drag and drop on table view
      • From: "J.E. Schotsman" <email@hidden>
  • Prev by Date: Re: Migrating shared library plugins to Cocoa Touch Frameworks
  • Next by Date: Re: Drag and drop on table view
  • Previous by thread: strange NSOpenPanel behavior
  • Next by thread: Re: Drag and drop on table view
  • Index(es):
    • Date
    • Thread