Re: NSOutlineView edit row problem
Re: NSOutlineView edit row problem
- Subject: Re: NSOutlineView edit row problem
- From: Fredrik Olsson <email@hidden>
- Date: Thu, 13 Jul 2006 09:05:39 +0200
David Chan skrev:
Hi all,
I understand that the normal behavior of nsoutlineview or nstableview
is that when you edit a row and you press return key, it would move to
the next row and set that new row into edit state. How can I intercept
this process so that upon user pressing return key, the view will not
highlight the next row? I want the view to just commit the editing and
select the same row in a non-edit state.
Thank you in advance.
This little category solved my problem:
@implementation NSOutlineView (EnterEndsEditing)
- (void)textDidEndEditing:(NSNotification*)notification
{
if ([[[notification userInfo] objectForKey:@"NSTextMovement"]
intValue] == NSReturnTextMovement) {
NSMutableDictionary *newUserInfo = [NSMutableDictionary
dictionaryWithDictionary:[notification userInfo]];
[newUserInfo setObject:[NSNumber
numberWithInt:NSIllegalTextMovement] forKey:@"NSTextMovement"];
NSNotification *newNotification = [NSNotification
notificationWithName:[notification name]
object:[notification object] userInfo:newUserInfo];
[super textDidEndEditing:newNotification];
[[self window] makeFirstResponder:self];
} else {
[super textDidEndEditing:notification];
}
}
@end
// Fredrik Olsson
Regards
David
_______________________________________________
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
_______________________________________________
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