Re: Row dragging ...
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.