• 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
Re: validateDrop in NSTableView never called
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: validateDrop in NSTableView never called


  • Subject: Re: validateDrop in NSTableView never called
  • From: Tristan Jehan <email@hidden>
  • Date: Sat, 8 Apr 2006 16:33:45 -0400

August,

Thanks. I'm implementing these methods in the data source object (my NSArrayController subclass) as linked by Interface Builder. The first one (tableView:writeRowsWithIndexes:toPasteboard:) gets called just fine, and fills in the pasteboard before returning YES. As far as I understand, this method and the others should be in the same place. The second though (tableView:validateDrop:proposedRow:proposedDropOperation:) never gets called when dragging.


- (BOOL) tableView: (NSTableView *)tv
writeRowsWithIndexes: (NSIndexSet *)indexes
toPasteboard: (NSPasteboard *)pboard
{
NSArray *typesArray = [NSArray arrayWithObjects:CopiedRowsType, MovedRowsType, nil];
[pboard declareTypes:typesArray owner:self];
[pboard setPropertyList:indexes forType:MovedRowsType];
NSMutableArray *rowCopies = [NSMutableArray arrayWithArray: [[self arrangedObjects] objectsAtIndexes: indexes]];
[pboard setPropertyList:rowCopies forType:CopiedRowsType];

return YES;
}


- (NSDragOperation) tableView: (NSTableView *)tv
                 validateDrop: (id <NSDraggingInfo>)info
                  proposedRow: (int)row
        proposedDropOperation: (NSTableViewDropOperation)op
{
	NSLog(@"Entered validateDrop"); // Never gets here...
    NSDragOperation dragOp = NSDragOperationCopy;
    if ([info draggingSource] == tableView) {
		dragOp =  NSDragOperationMove;
    }
    [tv setDropRow:row dropOperation:NSTableViewDropAbove];

    return dragOp;
}

Tristan





On Apr 8, 2006, at 4:18 PM, August Trometer wrote:

Without seeing a code sample, I'd bet that you're not implementing this in the right place.

tableView:validateDrop:proposedRow:proposedDropOperation is a data source method meaning that you need to implement it in the object you have set as the table's data source. This could be the NSTableView itself (though that would be weird) or it could be the NSArrayController or some other object.

-- August





On Apr 8, 2006, at 3:39 PM, Tristan Jehan wrote:

I've been struggling with drag-and-drop in an NSTableView for a while now.

I have an NSTableView setup like in the "Bookmarks" example. The data source and delegate of it is a subclass of an NSArrayController where is implemented at least the three methods: tableView:writeRowsWithIndexes:toPasteboard:, tableView:validateDrop:proposedRow:proposedDropOperation:, and tableView: acceptDrop:row:dropOperation:

I register the drag-and-drop in the awakeFromNib function of that NSArrayController with: [tableView registerForDraggedTypes: [NSArray arrayWithObjects: CopiedRowsType, MovedRowsType, nil]]; and that gets passed just fine.

At runtime, tableView:writeRowsWithIndexes:toPasteboard: gets called and returns YES. However tableView:validateDrop:proposedRow:proposedDropOperation: and tableView: acceptDrop:row:dropOperation: never get called and the dragged row goes back to its initial location. What am I possibly doing wrong? Thanks.

Tristan
_______________________________________________
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


_______________________________________________ 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
  • Follow-Ups:
    • Re: validateDrop in NSTableView never called
      • From: Jerry Krinock <email@hidden>
References: 
 >validateDrop in NSTableView never called (From: Tristan Jehan <email@hidden>)
 >Re: validateDrop in NSTableView never called (From: August Trometer <email@hidden>)

  • Prev by Date: Re: validateDrop in NSTableView never called
  • Next by Date: NSArrayController - limiting number of values
  • Previous by thread: Re: validateDrop in NSTableView never called
  • Next by thread: Re: validateDrop in NSTableView never called
  • Index(es):
    • Date
    • Thread