Re: Stopping edition of a NSTableView's row after hitting return
Re: Stopping edition of a NSTableView's row after hitting return
- Subject: Re: Stopping edition of a NSTableView's row after hitting return
- From: Larry Fransson <email@hidden>
- Date: Fri, 4 Feb 2005 12:43:55 -0800
On Feb 4, 2005, at 10:00, Jerome Foucher wrote:
Can someone tell me how to stop the edition ?
Subclass NSTableView and override -textDidEndEditing: to catch returns and end editing. Normally, I'd refer you to the archives, since that's where I got much of my code. But since it took me considerable time to actually get it working, I'll post it here for you and posterity.
- (void)textDidEndEditing:(NSNotification *)notification
{
if([[[notification userInfo] valueForKey:@"NSTextMovement"] intValue] == NSReturnTextMovement) {
NSMutableDictionary *newUserInfo;
newUserInfo = [[NSMutableDictionary alloc]
initWithDictionary:[notification userInfo]];
[newUserInfo setObject:[NSNumber numberWithInt:NSIllegalTextMovement]
forKey:@"NSTextMovement"];
notification = [NSNotification notificationWithName:[notification name]
object:[notification object]
userInfo:newUserInfo];
[super textDidEndEditing:notification];
[newUserInfo release];
[[self window] makeFirstResponder:self];
//Notification that table view has ended all editing
[[NSNotificationCenter defaultCenter] postNotificationName:PFTableViewDidEndAllEditingNotification object:self];
//Delegate endEditing
id delg = [self delegate];
SEL ds = @selector(tableViewDidEndAllEditing:);
if([delg respondsToSelector:ds]) [delg performSelectorOnMainThread:ds withObject:self waitUntilDone:NO];
}
else {
[super textDidEndEditing:notification];
}
}
Note that everything from the "//Notification..." comment to the end of the block is my own code added for my own purposes, and is not required in order to do what you want.
Larry Fransson
Seattle, WA
_______________________________________________
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