Use ...ForNode: methods so that the path is dependent on the kind of node

This commit is contained in:
Gregory John Casamento 2024-07-03 04:08:43 -04:00
parent ebf6bdb8d2
commit 7aee7f6667
2 changed files with 18 additions and 5 deletions

View file

@ -458,15 +458,15 @@ static NSImage *unexpandable = nil;
BOOL leaf = YES;
id observedObject = [theBinding observedObject];
NSTreeController *tc = (NSTreeController *)observedObject;
NSString *leafKeyPath = [tc leafKeyPath];
NSString *leafKeyPath = [tc leafKeyPathForNode: item];
if (leafKeyPath == nil)
{
NSString *countKeyPath = [tc countKeyPath];
NSString *countKeyPath = [tc countKeyPathForNode: item];
if (countKeyPath == nil)
{
NSString *childrenKeyPath = [tc childrenKeyPath];
NSString *childrenKeyPath = [tc childrenKeyPathForNode: item];
if (childrenKeyPath == nil)
{
@ -2077,11 +2077,11 @@ Also returns the child index relative to this parent. */
if ([self isExpandable: startitem] // leaf == NO
&& [self isItemExpanded: startitem])
{
NSString *childrenKeyPath = [tc childrenKeyPath];
NSString *childrenKeyPath = [tc childrenKeyPathForNode: startitem];
if (childrenKeyPath != nil)
{
NSString *countKeyPath = [tc countKeyPath];
NSString *countKeyPath = [tc countKeyPathForNode: startitem];
children = [sitem valueForKeyPath: childrenKeyPath];
if (countKeyPath == nil)

View file

@ -263,6 +263,19 @@
if ([self canAddChild]
&& [self countKeyPath] == nil)
{
id newObject = [self newObject];
if (newObject != nil)
{
NSMutableArray *newContent = [NSMutableArray arrayWithArray: [self content]];
GSControllerTreeProxy *node = [[GSControllerTreeProxy alloc]
initWithRepresentedObject: newObject
withController: self];
[newContent addObject: node];
[self setContent: newContent];
RELEASE(newObject);
}
}
}