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                 s...@rogue-research.com
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to