mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 04:42:29 +00:00
customTableView now does not rely on windowController for observer lookup
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "MPModelChangeObserving.h"
|
||||
|
||||
@interface MPCustomFieldTableCellView : NSTableCellView
|
||||
|
||||
@@ -14,4 +15,6 @@
|
||||
@property (nonatomic, weak) IBOutlet NSTextField *valueTextField;
|
||||
@property (nonatomic, weak) IBOutlet NSButton *removeButton;
|
||||
|
||||
@property (weak) id<MPModelChangeObserving> observer;
|
||||
|
||||
@end
|
||||
|
||||
@@ -25,10 +25,12 @@
|
||||
|
||||
- (void)setValue:(id)value forKeyPath:(NSString *)keyPath {
|
||||
if([keyPath hasPrefix:@"objectValue."]) {
|
||||
[self.window.windowController.document willChangeModelProperty];
|
||||
[self.observer willChangeModelProperty];
|
||||
[super setValue:value forKeyPath:keyPath];
|
||||
[self.observer didChangeModelProperty];
|
||||
}
|
||||
else {
|
||||
[super setValue:value forKeyPath:keyPath];
|
||||
[self.window.windowController.document didChangeModelProperty];
|
||||
}
|
||||
[super setValue:value forKeyPath:keyPath];
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -43,6 +43,8 @@
|
||||
view.removeButton.action = @selector(removeCustomField:);
|
||||
view.removeButton.tag = row;
|
||||
|
||||
view.observer = tableView.window.windowController.document;
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
}
|
||||
|
||||
- (void)didLoadView {
|
||||
[self.pluginDataController bind:NSContentDictionaryBinding toObject:self.representedObject withKeyPath:NSStringFromSelector(@selector(customData)) options:nil];
|
||||
[self.pluginDataController bind:NSContentDictionaryBinding toObject:self.representedObject withKeyPath:NSStringFromSelector(@selector(mutableCustomData)) options:nil];
|
||||
[self.pluginDataTabelView bind:NSContentBinding toObject:self.pluginDataController withKeyPath:NSStringFromSelector(@selector(arrangedObjects)) options:nil];
|
||||
self.pluginDataTabelView.backgroundColor = [NSColor clearColor];
|
||||
}
|
||||
@@ -60,6 +60,7 @@
|
||||
toObject:view
|
||||
withKeyPath:[NSString stringWithFormat:@"%@.%@", NSStringFromSelector(@selector(objectValue)), NSStringFromSelector(@selector(key))]
|
||||
options:nil];
|
||||
view.observer = self.observer;
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,4 +18,4 @@
|
||||
- (void)didLoadView;
|
||||
- (void)updateResponderChain;
|
||||
|
||||
@end
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user