Re: What to subclass in NSArrayController to enable immediate editing of added rows?
Re: What to subclass in NSArrayController to enable immediate editing of added rows?
- Subject: Re: What to subclass in NSArrayController to enable immediate editing of added rows?
- From: "Sean McBride" <email@hidden>
- Date: Tue, 1 Dec 2009 16:44:04 -0500
- Organization: Rogue Research Inc.
On 11/30/09 7:57 PM, David Hirsch said:
>I'm trying to have my table immediately enable editing of added
>items.
I have a handy NSTableView category to do that:
- (void)makeEditableSelectedCellOfColumnIdentifier:(NSString*)
inColumnIdentifier
{
NSTableColumn* column = [self tableColumnWithIdentifier:inColumnIdentifier];
if (column && ![column isHidden])
{
if ([self numberOfSelectedRows] == 1)
{
NSInteger columnIndex = [self columnWithIdentifier:inColumnIdentifier];
NSInteger selectRowIndex = [self selectedRow];
if ((columnIndex != -1) && (selectRowIndex != -1))
{
[self editColumn:columnIndex row:selectRowIndex withEvent:nil select:YES];
}
}
}
}
So in response to some "add" button in the UI, I have an action method
that does:
foo = [arrayController newObject]
[arrayController setSelectedObjects:[NSArray arrayWithObject:foo]]
[tableView scrollRowToVisible:[tableView selectedRow]];
[tableView makeEditableSelectedCellOfColumnIdentifier:@"bar"];
hth,
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden