• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: stop editing cells in tableview
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: stop editing cells in tableview


  • Subject: Re: stop editing cells in tableview
  • From: Cryx <email@hidden>
  • Date: Mon, 17 Jun 2002 01:45:02 -0500

On Sunday, June 16, 2002, at 04:31 PM, Guillaume Rager wrote:
i just want to know how to stop the next cell editing in tableview. I mean, you're editing a TextFieldCell in a TableView and when you finish, you type Enter and the next cell is editing, so i don't need that.

I just wasted, err spent, most of today tracking down this same elusive question. I seem to recall I found this code in a post by Ondra on mamasam (which I think he took from someone else). It's a filthy hack, but it works. I can't believe such commonly desired functionality is not implemented in the interface. I tried various other methods, then gave up and used this:

- (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];
}
}


Daryn
_______________________________________________
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.

References: 
 >stop editing cells in tableview (From: Guillaume Rager <email@hidden>)

  • Prev by Date: displaying folder contents in an NSOutlineView
  • Next by Date: Re: Printing in OSX...
  • Previous by thread: stop editing cells in tableview
  • Next by thread: displaying folder contents in an NSOutlineView
  • Index(es):
    • Date
    • Thread