Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Callbacks When an NSScrollView is Scrolled?

I'm making a Mac app which needs to know when the user is scrolling the NSScrollView, however, I can't find any methods like UIScrollView, which has the following delegate methods:

– scrollViewDidScroll: – scrollViewWillBeginDragging: – scrollViewDidEndDragging:willDecelerate: – scrollViewShouldScrollToTop: – scrollViewDidScrollToTop: – scrollViewWillBeginDecelerating: – scrollViewDidEndDecelerating: 

Can I have the similar delegate methods for the App Kit? Thanks in advance.

Kai.

like image 533
nonamelive Avatar asked Mar 02 '11 15:03

nonamelive


1 Answers

You can monitor a scroll view's changes by monitoring the bounds of it's content view. First set the content view to post its changes with

[contentView setPostsBoundsChangedNotifications:YES]; 

Then register as an observer of those notifications with

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(boundsDidChange:) name:NSViewBoundsDidChangeNotification object:contentView];  
like image 58
Sean Rich Avatar answered Sep 29 '22 13:09

Sean Rich