• 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: Changing editing behaviour of NSTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing editing behaviour of NSTableView


  • Subject: Re: Changing editing behaviour of NSTableView
  • From: Brian Webster <email@hidden>
  • Date: Tue, 21 Jan 2003 09:08:15 -0600

This method should do what you want (courtesy of OmniAppKit). You should subclass NSTableView and include this method in your subclass.

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


On Tuesday, January 21, 2003, at 05:59 AM, email@hidden wrote:

By default, editing a row in an NSTableView and hitting return selects
the next row for editing (or the current one again if there is only one
row in the table.)

What I'd like to have it do is have hitting return end the editing the
leave the just-edited row selected.

Anyone got an idea on how to do this?

I've tried various things in the delegate's
tableView:setObjectValue:forTableColumn: method, but I think the switch
to editing the next row happens after this method is called.

--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster
_______________________________________________
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.

  • Prev by Date: Where to put code to create automaticly a box in a NSPanel
  • Next by Date: Printing a selection (newbie)
  • Previous by thread: Changing editing behaviour of NSTableView
  • Next by thread: COCOA: Simplest Way of Formatted Text
  • Index(es):
    • Date
    • Thread