• 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: What to subclass in NSArrayController to enable immediate editing of added rows?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: What to subclass in NSArrayController to enable immediate editing of added rows?
      • From: David Hirsch <email@hidden>
  • Prev by Date: Re: problem encoding large float* matrix
  • Next by Date: Re: What to subclass in NSArrayController to enable immediate editing of added rows?
  • Previous by thread: Re: removing all sublayers from a layer with fast enumeration
  • Next by thread: Re: What to subclass in NSArrayController to enable immediate editing of added rows?
  • Index(es):
    • Date
    • Thread