• 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
Drag and drop between two table views.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Drag and drop between two table views.


  • Subject: Drag and drop between two table views.
  • From: Paul Johnson <email@hidden>
  • Date: Mon, 25 Oct 2010 16:54:47 -0500

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 (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Drag and drop between two table views.
      • From: Graham Cox <email@hidden>
  • Prev by Date: Thread not registered mystery under GC
  • Next by Date: Move UINavigationBar down?
  • Previous by thread: Re: Thread not registered mystery under GC
  • Next by thread: Re: Drag and drop between two table views.
  • Index(es):
    • Date
    • Thread