Re: NSTableView - howto implement textShouldBeginEditing:
Re: NSTableView - howto implement textShouldBeginEditing:
- Subject: Re: NSTableView - howto implement textShouldBeginEditing:
- From: Rob In der Maur <email@hidden>
- Date: Thu, 22 May 2003 21:39:08 +0200
Dunker,
W.r.t. your second question, I think this is the piece of code you're
after (me is not the author, just got hold of it some time ago...):
- (void)textDidEndEditing:(NSNotification *)notification;
{
if ([[[notification userInfo] objectForKey:@"NSTextMovement"]
intValue] == NSReturnTextMovement) {
// This is ugly, but just about the only way to do it.
// NSTableView is determined to select and edit something else,
// even the text field that it just finished editing, unless we
mislead it about what key was pressed to end editing.
NSMutableDictionary *newUserInfo;
NSNotification *newNotification;
newUserInfo = [NSMutableDictionary
dictionaryWithDictionary:[notification userInfo]];
[newUserInfo setObject:[NSNumber
numberWithInt:NSIllegalTextMovement] forKey:@"NSTextMovement"];
newNotification = [NSNotification
notificationWithName:[notification name] object:[notification object]
userInfo:newUserInfo];
[super textDidEndEditing:newNotification];
// For some reason we lose firstResponder status when when we
do the above.
[[self window] makeFirstResponder:self];
} else {
[super textDidEndEditing:notification];
}
}
cheers
Rob
On Thursday, May 22, 2003, at 19:34 Europe/Amsterdam, Dunker wrote:
Hi,
this might sound stupid, but how does one implement the delegate
methods textShouldBeginEditing: and textShouldStopEditing: in the
delegate of an NSTableView? I think I do understand how delegates work
and have no problem implementing the other delegate methods. However,
the two methods mentioned actually never get called at all.
Do I have to make the delegate the observer for some notification? If
so, which one?
Also, here comes another question: how does one stop the automatic
selection and editing of the next row in NSTableView, once the user
presses return while editing? This question has popped up several
times in different forums, but was never answered. If this really is
an unknown secret, please let me know! =8-]
Thanks for help,
Knud
-----------------------------------------------------------------------
--------
Knud Mvller - Institut f|r Sprachliche Informationsveratbeitung,
Universitdt zu Kvln
(Department of Linguistic Data Processing, University of Cologne,
Germany)
_______________________________________________
MacOSX-dev mailing list
email@hidden
http://www.omnigroup.com/mailman/listinfo/macosx-dev
- Rob In der Maur
_______________________________________________
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.