• 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
Rearranging NSTableView by dragging
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Rearranging NSTableView by dragging


  • Subject: Rearranging NSTableView by dragging
  • From: Mark Dawson <email@hidden>
  • Date: Mon, 11 Jul 2005 18:20:50 -0700

I'd like to add support for rearranging a table view by dragging a selected row around.

From what I can gather from documentation and searches, I need to subclass my NSTableView and add a few methods. My current app needs to run on 10.2, so bindings are out (if that makes a difference). It doesn't make sense for a user to be able to drag in our out these rows anywhere else (outside of maybe implementing a drag-to-trash=delete row).

What I'm not clear about is what exactly I need to implement to get rearranging to work. What I know is that what I have doesn't do anything (none of the methods are called when I click on a row and try to drag it). My awakefromnib DOES get called, just not the other two methods.

I think I need to add the following methods:
// This method will be called repeatedly during a drag in, to validate it and to determine the operation type and drop location- (NSDragOperation) tableView: (NSTableView *) tableView
validateDrop: (id <NSDraggingInfo>) info
proposedRow: (int) row
proposedDropOperation: (NSTableViewDropOperation) operation



// This method will be called when a drag in is finally dropped on our table view
- (BOOL)tableView:(NSTableView *)tv acceptDrop:(id <NSDraggingInfo>)info row:(int)row dropOperation:(NSTableViewDropOperation)op {


// ** What I'm not sure about how I set up what type/kind of drag is occurring (i.e., nothing from the desktop or file would be dragged in, so I assume I want a custom type that may just include the the original index)
-(void)awakeFromNib
{
if ([[self superclass] instancesRespondToSelector:@selector(awakeFromNib)])
{
[super awakeFromNib];
}
[self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, nil]];


	[self setVerticalMotionCanBeginDrag:YES];
}
_______________________________________________
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: Rearranging NSTableView by dragging
      • From: Scott Anguish <email@hidden>
  • Prev by Date: Re: Why does this leak memory?
  • Next by Date: RE: Why does this leak memory?
  • Previous by thread: Re: Two sheets related questions
  • Next by thread: Re: Rearranging NSTableView by dragging
  • Index(es):
    • Date
    • Thread