I am trying to drag and drop from one text view to another. I can write an
index set of copied rows to the pasteboard using:


- (BOOL)tableView:(NSTableView *)tv

writeRowsWithIndexes:(NSIndexSet *)rowIndexes

        toPasteboard:(NSPasteboard*)pboard {

  // Copy the row numbers to the pasteboard.

  NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];

  [pboard declareTypes:[NSArray arrayWithObject:NSDragPboard] owner:self];

  [pboard setData:data forType:NSDragPboard];

  return YES;

}


In the array controller for the destination text view, I have


- (BOOL)tableView:(NSTableView *)aTableView

       acceptDrop:(id <NSDraggingInfo>)info

              row:(NSInteger)row

    dropOperation:(NSTableViewDropOperation)operation

{

  NSPasteboard* pboard = [info draggingPasteboard];

  NSData* rowData = [pboard dataForType:NSDragPboard];

  NSIndexSet* rowIndexes = [NSKeyedUnarchiver unarchiveObjectWithData
:rowData];

  NSInteger dragRow = [rowIndexes firstIndex];



  // Move the specified row to its new location...

  NSLog(@"count = %i", [rowIndexes count]);

  while(dragRow != NSNotFound)

  {

    NSLog(@" %i", dragRow);

    dragRow = [rowIndexes indexGreaterThanIndex:dragRow];

    // **** Copy a row here. ****

  }

  return YES;

}


I'm having trouble figuring out the correct code in the while-loop where I
need to copy a row.


As you can see, I'm new at this, but perhaps someone can lead me in the
right direction. Thanks.
_______________________________________________

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

Reply via email to