Simple drag problem
Simple drag problem
- Subject: Simple drag problem
- From: Andy Bettis <email@hidden>
- Date: Mon, 27 Jun 2005 13:57:56 +0100
Hi folks,
I'm trying to implement drag and drop to reorder items in an
NSTableView. The drag works fine but when I do the drop the item
always zooms back to its origin. In the debugger neither my
validateDrop or acceptDrop methods are called. The code is:
- (BOOL)tableView:(NSTableView*) inTable writeRowsWithIndexes:
(NSIndexSet*) inIndexes toPasteboard:(NSPasteboard*) inPboard
{
BOOL allowDrag = NO;
if (inTable == categoriesList) {
allowDrag = YES;
[inPboard declareTypes:[NSArray
arrayWithObject:NSStringPboardType] owner:categoriesList];
NSString* theRow = [NSString stringWithFormat:@"%d",
[inIndexes firstIndex]];
[inPboard setString:theRow forType:NSStringPboardType];
}
return(allowDrag);
}
- (NSDragOperation)tableView:(NSTableView*) inTable validateDrop:(id
<NSDraggingInfo>) inInfo
proposedRow:(int) inRow proposedDropOperation:
(NSTableViewDropOperation) inOperation
{
return(NSDragOperationMove);
}
- (BOOL)tableView:(NSTableView*) inTable acceptDrop:(id
<NSDraggingInfo>) inInfo
row:(int) inRow dropOperation:(NSTableViewDropOperation)
inOperation
{
int theFromRow = [[[inInfo draggingPasteboard]
stringForType:NSStringPboardType] intValue];
if (theFromRow != inRow) {
// Do clever updating
}
return(YES);
}
The table view is uneditable, and is being shown inside a sheet. Is
there anything obviously wrong here?
Many thanks
Rev. Andy
_______________________________________________
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