Re: tableView Drag and Drop frustration
Re: tableView Drag and Drop frustration
- Subject: Re: tableView Drag and Drop frustration
- From: Kurt Marek <email@hidden>
- Date: Sun, 2 Nov 2003 08:59:48 -0800
I guess it would be helpful if someone could give me an example here. I
declared the type in the source, as follows:
- (BOOL) tableView: (NSTableView *) view
writeRows: (NSArray *) rows
toPasteboard: (NSPasteboard *) pboard
{
NSLog(@"dragging");
id object = [[self arrangedObjects] objectAtIndex: [[rows
lastObject] intValue]];
NSData *data = [NSArchiver archivedDataWithRootObject: object];
[pboard declareTypes: [NSArray arrayWithObject:
@"NSGeneralPboardType"]
owner: nil];
[pboard setData: data forType: @"NSGeneralPboardType"];
return YES;
}
For the destination table, I issue the following:
[sourceTableView registerForDraggedTypes: [NSArray
arrayWithObjects:@"NSGeneralPboardType", nil]];
I have the following methods in the datasource of the destination:
- (NSDragOperation) tableView: (NSTableView *) view
validateDrop: (id <NSDraggingInfo>) info
proposedRow: (int) row
proposedDropOperation: (NSTableViewDropOperation) operation
{
NSLog(@"drag operation");
// }
}
- (BOOL) tableView: (NSTableView *) view
acceptDrop: (id <NSDraggingInfo>) info
row: (int) row
dropOperation: (NSTableViewDropOperation) operation
{
//
}
The build works fine and I can drag a row out of the source table, but
there is no indication that (NSDragOperation) tableView: (NSTableView
*) view... is ever called. I think I am still having trouble with the
initial registerForDraggedTypes. Any help would be really appreciated.
Kurt
On Nov 1, 2003, at 10:34 PM, mmalcolm crawford wrote:
On Nov 1, 2003, at 9:56 PM, Kurt Marek wrote:
[destinationTableView registerForDraggedTypes: [NSArray
arrayWithObjects:NSGeneralPboardType, nil]];
The problem is that I get an error saying that NSGeneralPboardType is
undeclared in that last line of code.
NSGeneralPboard identifies the usual copy pasteboard
(<http://developer.apple.com/documentation/Cocoa/Conceptual/
CopyandPaste/Concepts/NamedPasteboards.html>). There are a number of
other constants which identify the data the pasteboard may contain,
including NSFileContentsPboardType, NSStringPboardType and
NSTIFFPboardType (see:
<http://developer.apple.com/documentation/Cocoa/Conceptual/
CopyandPaste/Concepts/DataTypes.html>).
Looking at the documentation, it doesn't appear that
NSGeneralPboardType is a stock type, but copying a dictionary doesn't
fall into any of the stock types. How do I get around this?
You should define a custom type for your own data.
"Types other than those listed above [DataTypes.html] can also be
used. For example, your application may keep data in a private format
that is richer than any of the existing types. That format can also be
used as a pasteboard type."
mmalc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.