Add code to set selection indexes on the controller

This commit is contained in:
Gregory John Casamento 2024-07-16 18:03:30 -04:00
parent c39095cd61
commit c68c459584
2 changed files with 21 additions and 0 deletions

View file

@ -147,6 +147,7 @@
if (self == [NSArrayController class])
{
[self exposeBinding: NSContentArrayBinding];
[self exposeBinding: NSSelectionIndexesBinding];
[self setKeys: [NSArray arrayWithObjects: NSContentBinding, NSContentObjectBinding, nil]
triggerChangeNotificationsForDependentKey: @"arrangedObjects"];
}

View file

@ -6713,6 +6713,26 @@ For a more detailed explanation, -setSortDescriptors:. */
- (void) _postSelectionDidChangeNotification
{
NSTableColumn *tb = [_tableColumns objectAtIndex: 0];
GSKeyValueBinding *theBinding;
theBinding = [GSKeyValueBinding getBinding: NSValueBinding
forObject: tb];
// If there is a binding, send the indexes back
if (theBinding != nil)
{
id observedObject = [theBinding observedObject];
// Set the selection indexes on the controller...
theBinding = [GSKeyValueBinding getBinding: NSSelectionIndexesBinding
forObject: observedObject];
if (theBinding != nil)
{
[theBinding reverseSetValue: _selectedRows];
}
}
[nc postNotificationName: NSTableViewSelectionDidChangeNotification
object: self];
}