Re: Restoring Tiger NSTableView behaviour in Leopard
Re: Restoring Tiger NSTableView behaviour in Leopard
- Subject: Re: Restoring Tiger NSTableView behaviour in Leopard
- From: Corbin Dunn <email@hidden>
- Date: Fri, 11 Apr 2008 14:45:37 -0700
Thank you; that fixed it. Here is my solution (for a 4-column table):
-(void)textDidEndEditing:(NSNotification *)notification
{
NSInteger editedColumn = [self editedColumn];
NSInteger editedRow = [self editedRow];
NSDictionary *userInfo = [notification userInfo];
int textMovement = [[userInfo valueForKey:@"NSTextMovement"]
intValue];
if (textMovement == NSTabTextMovement)
{
[super textDidEndEditing:notification];
if (editedColumn == 3)
{
// Select row before calling -(void)editColumn:, and then start
editing
[self selectRowIndexes:[NSIndexSet indexSetWithIndex:editedRow+1]
byExtendingSelection:NO];
[self editColumn:0 row:editedRow+1 withEvent:nil select:YES];
}
}
else if (textMovement == NSBacktabTextMovement)
{
[super textDidEndEditing:notification];
if (editedColumn == 0)
{
// Select row before calling -(void)editColumn:, and then start
editing
[self selectRowIndexes:[NSIndexSet indexSetWithIndex:editedRow-1]
byExtendingSelection:NO];
[self editColumn:3 row:editedRow-1 withEvent:nil select:YES];
}
}
else
[super textDidEndEditing:notification];
Looks good. You could abstract it using [self numberOfColumns] - 1
instead of 3. Also, add in bounds checks like if editedRow < ([self
numberOfRows] - 1) then inc row ... and if editedRow > 0) then dec row.
corbin
_______________________________________________
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