One Quickie


Responding to a scrollview scrolling (NSScrollView->General)
If you need to react to a scrollview being scrolled by the user, first tell the contentView (the NSClipView) to post notifications when its bounds changes, and then register to receive an NSViewBoundsDidChangeNotification:
    [[scrollView contentView] setPostsBoundsChangedNotifications: YES];

    NSNotificationCenter *center = [NSNotificationCenter defaultCenter] ;
    [center addObserver: self
            selector: @selector(boundsDidChangeNotification:)
            name: NSViewBoundsDidChangeNotification
            object: [scrollView contentView]];
...

- (void) boundsDidChangeNotification: (NSNotification *) notification
{
    [self setNeedsDisplay: YES];
    // or whatever work you need to do

} // boundsDidChangeNotification



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com