• 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: David Hirsch <email@hidden>
  • Date: Tue, 01 Dec 2009 13:51:57 -0800

Well, that is a nice bit of code to have, but it doesn't really address the issue. As I wrote in my original post, there are a number of published methods for handing this in (for example) the NSDocument subclass. What *I* want to do is handle it in my NSArrayController subclass, for encapsulation purposes - I have a number of different tables for which I want to enable this, and I'd like to keep the functionality separate. I am looking into the suggestion of subclassing NSArrayController's addObject: method, which seems likely to work.

Also, the scrollRowToVisible call is superfluous, since the editColumn:row:withEvent:select: method is documented to do the scrolling for you already. And, I think the setSelectedObjects can be replaced by a checkbox in IB, right? (Although perhaps under some circumstances you would not like the added row to be selected?)
-Dave


On Dec 1, 2009, at 1:44 PM, Sean McBride wrote:

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




============================
Dave Hirsch
Associate Professor
Department of Geology
Western Washington University
persistent email: email@hidden
http://www.davehirsch.com
voice: (360) 389-3583
aim: email@hidden
vCard: http://almandine.geol.wwu.edu/~dave/personal/DaveHirsch.vcf
============================



_______________________________________________

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: "Sean McBride" <email@hidden>
References: 
 >Re: What to subclass in NSArrayController to enable immediate editing of added rows? (From: "Sean McBride" <email@hidden>)

  • Prev by Date: Re: What to subclass in NSArrayController to enable immediate editing of added rows?
  • Next by Date: Re: What to subclass in NSArrayController to enable immediate editing of added rows?
  • Previous by thread: Re: What to subclass in NSArrayController to enable immediate editing of added rows?
  • Next by thread: Re: What to subclass in NSArrayController to enable immediate editing of added rows?
  • Index(es):
    • Date
    • Thread