Update to use NSObservedKeyPathKey instead of string, add code to _setObjectValue:... in NSTableView to set the value when we have a binding

This commit is contained in:
Gregory John Casamento 2024-07-10 06:31:55 -04:00
parent 060b27a854
commit aa86a96c55
2 changed files with 17 additions and 4 deletions

View file

@ -1892,7 +1892,7 @@ Also returns the child index relative to this parent. */
if (info != nil)
{
id theItem = [_items objectAtIndex: index];
NSString *ikp = [info objectForKey: @"NSObservedKeyPath"];
NSString *ikp = [info objectForKey: NSObservedKeyPathKey];
NSUInteger location = [ikp rangeOfString: @"."].location;
NSString *keyPath = (location == NSNotFound ? ikp : [ikp substringFromIndex: location + 1]);
@ -1927,7 +1927,7 @@ Also returns the child index relative to this parent. */
if (info != nil)
{
id theItem = [_items objectAtIndex: index];
NSString *ikp = [info objectForKey: @"NSObservedKeyPath"];
NSString *ikp = [info objectForKey: NSObservedKeyPathKey];
NSUInteger location = [ikp rangeOfString: @"."].location;
NSString *keyPath = (location == NSNotFound ? ikp : [ikp substringFromIndex: location + 1]);

View file

@ -6883,8 +6883,21 @@ For a more detailed explanation, -setSortDescriptors:. */
forTableColumn: (NSTableColumn *)tb
row: (NSInteger) index
{
if ([_dataSource respondsToSelector:
@selector(tableView:setObjectValue:forTableColumn:row:)])
GSKeyValueBinding *theBinding;
theBinding = [GSKeyValueBinding getBinding: NSValueBinding
forObject: tb];
if (theBinding != nil)
{
NSDictionary *info = [GSKeyValueBinding infoForBinding: NSValueBinding
forObject: tb];
id obj = [(NSArray *)[theBinding destinationValue]
objectAtIndex: index];
NSString *keyPath = [info objectForKey: NSObservedKeyPathKey];
[obj setValue: value forKeyPath: keyPath];
}
else if ([_dataSource respondsToSelector:
@selector(tableView:setObjectValue:forTableColumn:row:)])
{
[_dataSource tableView: self
setObjectValue: value