• 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: Row dragging ...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Row dragging ...


  • Subject: Re: Row dragging ...
  • From: Herr Witten <email@hidden>
  • Date: Sat, 31 Jan 2004 17:27:06 -0500

Since you are simply doing intra-table rearrangement, you can simplify the process by noting the objects to be moved and then simply moving them with code like this provided by Daryn, obviating the need to encode your objects:

@implementation NSMutableArray (MyArrayAdditions)

-(void)moveObjectAtIndex:(unsigned)index toIndex:(unsigned)newIndex {
[self moveObjectsFromIndices:&index numIndices:1 toIndex:newIndex];
}

-(void)moveObjectsFromIndices:(unsigned *)indices numIndices:(unsigned)count toIndex:(unsigned)index {
unsigned off1 = 0, off2 = 0;

while (count--) {
unsigned i = *indices++;

if (i < index) {
i -= off1++;
[self insertObject:[self objectAtIndex:i] atIndex:index];
[self removeObjectAtIndex:i];
} else {
[self insertObject:[self objectAtIndex:i] atIndex:index+off2++];
[self removeObjectAtIndex:i+1];
}
}
}

@end

On 31 Jan 2004, at 4:44 PM, J Nozzi wrote:

I've been searching and searching and unable to find a clear, concise answer to the following:

How in the world do you make an NSTableView able to respond to row drags? I want the user to be able to re-order rows (not columns) with a drag operation.

If anyone has a very simple explanation, I'd be most appreciative.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Row dragging ... (From: J Nozzi <email@hidden>)

  • Prev by Date: Re: Initialize Cocoa/ObjC from a dynamically-loaded bundle?
  • Next by Date: Duplicating the cosmetics of the System Preferences Panel
  • Previous by thread: Re: Row dragging ...
  • Next by thread: Re: Row dragging ...
  • Index(es):
    • Date
    • Thread