NSTableView Drag & Drop as a string
I have an NSTableView and I have Drag & Drop working between table views for my application where I encode the object to an NSData and write it to the NSPasteboard. But now I want to create a string representation of the object, add it to the pasteboard as well, and then when the object is dragged to something like an email, the string representation of the object is written in. The content does seem to be written to the pasteboard, but the "drop" doesn't seem to happen in an appropriate target (email message, editor, etc.) The same basic code works in -copy: but it doesn't seem to work in - tableView:writeRowsWithIndexes:toPasteboard: The line of code is: [pboard setString:str forType:NSStringPboardType]; Is there something different with the NSPasteboard passed into - tableView:writeRowsWithIndexes:toPasteboard: versus the pasteboard you get from [NSPasteboard generalPasteboard]? Any suggestions on what I am doing wrong? Thanks, Todd ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTableView Drag & Drop as a string
You haven't declared ownership of the pasteboard, so I imagine the system is somewhat confused. Fairly sure you need to do: [pboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:self]; [pboard setString:str forType:NSStringPboardType]; On 25 Sep 2009, at 02:58, Todd Heberlein wrote: I have an NSTableView and I have Drag & Drop working between table views for my application where I encode the object to an NSData and write it to the NSPasteboard. But now I want to create a string representation of the object, add it to the pasteboard as well, and then when the object is dragged to something like an email, the string representation of the object is written in. The content does seem to be written to the pasteboard, but the "drop" doesn't seem to happen in an appropriate target (email message, editor, etc.) The same basic code works in -copy: but it doesn't seem to work in - tableView:writeRowsWithIndexes:toPasteboard: The line of code is: [pboard setString:str forType:NSStringPboardType]; Is there something different with the NSPasteboard passed into - tableView:writeRowsWithIndexes:toPasteboard: versus the pasteboard you get from [NSPasteboard generalPasteboard]? Any suggestions on what I am doing wrong? Thanks, Todd ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net This email sent to cocoa...@mikeabdullah.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTableView Drag & Drop as a string
Solved it! ... But now I want to create a string representation of the object, add it to the pasteboard as well, and then when the object is dragged to something like an email, the string representation of the object is written in. The problem was that I was trying to do a cross-application drag and drop. The solution was to add to my -awakeFromNib method the line: [myTableView setDraggingSourceOperationMask:NSDragOperationEvery forLocal:NO]; This allows drag-and-drop across applications. Todd ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com