How to observe NSScroller changes?
- by Paperflyer
I have an NSScrollView subclass and I would like to update another NSView based on the current scroll position. I tried KVC-observing the value of [self horizontalScroller] but that never gets called.
// In awakeFromNib
[[self horizontalScroller] addObserver:self
forKeyPath:@"value"
options:NSKeyValueObservingOptionNew
context:NULL];
// Later in the file
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context {
if (object == [self horizontalScroller] && [keyPath isEqualToString:@"value"]) {
// This never gets called
}
}
Do you see an error in my reasoning or know a better method of how to observe the scrolling of an NSScrollview?