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]>
The way I got this code was by reading Aaron Hillegass' Cocoa Programming for Mac OS X and there was a specific section explaining how to Start editing a Row as soon as it is added and I've tried to adapt that code because he had an array controller and  I have a tree controller he called arrangedObjects then compared the object p to the ones in that array but calling arrangedObject on a tree controller does not return an array.

So I am not sure what I need to change/ What I've got wrong .

Josh.


________________________________
From: Christiaan Hofman <[email protected]>
To: Joshua Garnham <joshua.garnham-/[email protected]>
Sent: Sunday, 18 October, 2009 17:22:32
Subject: Re: Starting editing a Row as soon as it is Added.

Why don't you read the docs? It's all in there. And the answer is no.

Christiaan


On Oct 18, 2009, at 16:16, Joshua Garnham wrote:

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 <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 <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
>>
>>
>>
>>
>
>
>

Send instant messages to your online friends http://uk.messenger.yahoo.com
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.