Re: Starting editing a Row as soon as it is Added.

Joshua Garnham <joshua.garnham-/[email protected]>
Newsgroups gmane.comp.macosx.devel
Message-ID <[email protected]>
Ok, So do I need to retrieve all the objects in the Outline View to put in the NSArray?

And what is the Object p then if it's not an element in the array?


Josh.


________________________________
From: Christiaan Hofman <[email protected]>
To: Joshua Garnham <[email protected]>
Cc: [email protected]
Sent: Sunday, 18 October, 2009 14:51:40
Subject: Re: Starting editing a Row as soon as it is Added.



On Oct 18, 2009, at 14:20, Joshua Garnham wrote:

Oh, I see. 
>So from your reply I tried this:
>
>
>    NSObject *p = [treeController newObject];
>    [treeController addObject:p];
>    
>    // Find the row of the new
> object
>    NSArray *a = [treeController selectedNodes];
>    int row = [a indexOfObjectIdenticalTo:p];
>    
>    // Start editing in the first column
>    [outlineView editColumn:0
>                      row:row
>                withEvent:nil
>                  
> select:YES];
>
>However this still does not work, it just adds an object but does not begin editing it.
>
>Josh
>

And what makes you think that the index of the object in the selected nodes has anything to do with the row index in the outlineview? Moreover, why do you even think that the object p is an element of the array a (hint: it's not). 

Christiaan



________________________________
From: Christiaan Hofman <[email protected]>
>To: Joshua Garnham <[email protected]>
>Cc: [email protected]
>Sent: Sunday, 18 October, 2009 10:44:02
>Subject: Re: Starting editing a Row as soon as it is Added.
>
>
>On Oct 18, 2009, at 10:41, Joshua Garnham wrote:
>
>> I have an NSOutlineView and what I want to happen is that when a row is
>> added I want the row that has been added to Start Editing immediately
>> like when you double click on a row.
>> 
>> I've tried this:
>> 
>> NSObject *p = [treeController newObject];
>> [treeController addObject:p];
>> 
>> NSManagedObjectContext *moc = [self managedObjectContext];
>> NSEntityDescription *entityDescription =
> [NSEntityDescription
>> entityForName:@"projects" inManagedObjectContext:moc];
>> NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
>> [request setEntity:entityDescription];
>> 
>> NSError *error = nil;
>> NSArray *a = [moc executeFetchRequest:request error:&error];
>> 
>> // Find the row of the new object
>> int row = [a indexOfObjectIdenticalTo:p];
>> 
>> // Start editing in the second column
>> [outlineView editColumn:1
>>                    row:row
>>              withEvent:nil
>>                select:YES];
>> 
>> However, it
> seems that just edits any row in my Outline View.
>> What have I done wrong??
>> 
>> Josh
>
>I'm not surprised this won't work, I'm much more surprised you actually expect it to work. Why do you think that the index of an object in an arbitrary fetch result is in any way related to the row for that object in your outlineView?
>
>So you just need to figure out the row from inspection of the real display model, i.e. ask the treeController and/or the outlineView. You definitely want the treeController to select inserted objects, so you can just get the selected node afterwards. And you can get its row from the outlineView.
>
>Christiaan
>
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.