Re: Changing NSTableView cell editing behaviour
Re: Changing NSTableView cell editing behaviour
- Subject: Re: Changing NSTableView cell editing behaviour
- From: Allan Odgaard <email@hidden>
- Date: Tue, 2 Mar 2004 20:38:23 +0100
On 2. Mar 2004, at 19:17, Christoph Priebe wrote:
if I finish editing a string in a NSTableView cell by pressing
the return key the next cell is selected for editing. I would like to
change this default behaviour to just end the editing.
But how do I achieve this?
I don't think there is a nice way to do this, but I have subclasses my
table view and implement the textDidEndEditing: delegate method
(delegate for the field editor, which is used to edit the actual
cells).
To abort the editing I do the following:
// what made editing stop?
int movement = [[[aNotification userInfo]
objectForKey:@"NSTextMovement"] intValue];
// pass on info to superclass, which will advance the field editor
[super textDidEndEditing:aNotification];
// was the movement a return?
if(movement == NSReturnTextMovement)
{
// abort editing
[self abortEditing];
// aborting has the strange side-effect of making the table view
loose focus, so we re-activate it
[[self window] makeFirstResponder:self];
}
If anyone has a better solution, I would be delighted to know about it!
Likewise, I would love to be able to abort editing on escape (i.e.
revert to the state before editing started), but have not been able to
do that (I guess I would need to replace the field editor for the table
view, but that is really too much work).
_______________________________________________
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.