Re: Making an NSTableView accept drag operations
Re: Making an NSTableView accept drag operations
- Subject: Re: Making an NSTableView accept drag operations
- From: Wayne Pascoe <email@hidden>
- Date: Wed, 10 May 2006 17:23:15 +0100
On 10 May 2006, at 17:06, Nick Zitzmann wrote:
Try creating an outlet that points to the table view.
Sorry, I think I confused myself :(
What I've done is define an
IBOutlet NSTableView *tableView
in my DraggingFiles_AppDelegate.h file
I then dragged this to Interface Builder, and then control dragged
from the AppDelegate to the NSTableView and connected the tableView
outlet.
I also tried control dragging from my NSTableView to my
DraggingFiles_AppDelegate, selecting the Outlets tab and connecting
the delegate outlet.
I've also added the following to my DraggingFiles_AppDelegate.m:
- (void) awakeFromNib {
[tableView registerForDraggedTypes:[NSArray
arrayWithObjects:NSFilenamesPboardType, nil]];
NSLog(@"Awoke from NIB");
}
- (BOOL)tableView:(NSTableView *)tv writeRowsWithIndexes:(NSIndexSet
*)rowIndexes toPasteboard:(NSPasteboard*)pboard {
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];
[pboard declareTypes:[NSArray
arrayWithObject:NSFilenamesPboardType] owner:self];
[pboard setData:data forType:NSFilenamesPboardType];
return YES;
}
- (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id )info
proposedRow:(int)row proposedDropOperation:(NSTableViewDropOperation)
op {
NSLog(@"validate Drop");
return NSDragOperationEvery;
}
- (BOOL)tableView:(NSTableView*)tv acceptDrop:(id )info row:(int)row
dropOperation:(NSTableViewDropOperation)op {
NSLog(@"acceptDrop");
return YES;
}
I am still unable to drag a file to the tableview though. What am I
missing ?
--
Wayne Pascoe (gpg --keyserver www.co.uk.pgp.net --recv-keys 79A7C870)
Hanlon's Razor:
Never attribute to malice that which is adequately
explained by stupidity
Attachment:
PGP.sig
Description: This is a digitally signed message part
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden