Hi,
This was a reply that i posted recently for a similar question, i think you are missing step 2

To re-order the items in the tableView, you will have to implement a custom drag type.
Say for example you name your custom drag type as @"myDragType"
then
1] Register your table view to accept this drag type using "registerForDraggedTypes:" and passing an array containing @"myDragType" along with super's drag types 2] In your tableView's data source, implement this method "tableView:namesOfPromisedFilesDroppedAtDestination:forDraggedRowsWithIndexes :" and return an array containing @"myDragType". 3] Implement "tableView:writeRowsWithIndexes:toPasteboard:" in your data source and write any dummy data in the given pasteboard for type @"myDragType", this can be the data representing the items/indexes being dragged 4] Check for a valid drop with "tableView:validateDrop:proposedRow:proposedDropOperation:" 5] Finally set the new indexes for the dragged items in "tableView:acceptDrop:row:dropOperation:"
HTH,
Chaitanya

On 10-Dec-08, at 9:07 PM, Alex.Wang wrote:

Hi, everyone.
Currently I am working on a project which uses the NSOutlineview heavily. I thought the drag and drop functions are very important, so I am trying to
implement that.
However, after refer to some tutorials, I still can't make it work... My
steps are :
1. create a controller to manage the outlineview, set the controller to the
datasouce and delegate for the outlineview.
2. register the outineview with the following code in the awakeFromNib
method:
[_outlineView registerForDraggedTypes:
       [NSArray arrayWithObject:MyPrivateTableViewDataType]];
3. implement the following methods:
- (BOOL)outlineView:(NSOutlineView *)ov
        writeItems:(NSArray *)items
      toPasteboard:(NSPasteboard *)pboard
{

    draggedNodes = items;
   NSlog(@"In the outlinew writeItems method!");
    [pboard declareTypes:[NSArray
arrayWithObject:MyPrivateTableViewDataType] owner:self];
    [pboard setData:[NSData data] forType:MyPrivateTableViewDataType];

   return YES;
}

- (NSDragOperation)outlineView:(NSOutlineView*)ov
                 validateDrop:(id <NSDraggingInfo>)info
                 proposedItem:(id)item
           proposedChildIndex:(NSInteger)childIndex{

     NSLog(@"Return the NSDragOperation");
   draggedNodes = [[[info draggingSource] dataSource] draggedNodes];
       return NSDragOperationGeneric;
}

- (BOOL)outlineView:(NSOutlineView *)ov
        acceptDrop:(id <NSDraggingInfo>)info
              item:(id)item
        childIndex:(NSInteger)childIndex
{
  NSLog(@"should we return the accetpDrop?");
  return YES;
}

After compiled the application and set it up, I had no chance to
successfully get anything from the console although there are so many output
statements when I drag and drop items repeatly.
Can anyone here give me some help or guidance about this issue?
Thank you very much for any help. Good luck.

--
Best regards.
_______________________________________________

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/chaitanya%40expersis.com

This email sent to [EMAIL PROTECTED]

_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to