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.
Adding to @Sean Rich answer.
The
contentView
is theNSClipView
between theNSScrollView
andNSCollectionView
.For this to work, both the
ClipView
needs to be set topostsBoundsChangedNotifications
and should be passed in the notification object.my two cents for swift 4.2 OSX:
....
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
Then register as an observer of those notifications with
Had the same problem recently... To somewhat emulate deceleration callbacks it is possible to override
of NSScrollView class, but then check theEvent.momentumPhase instead of theEvent.phase for event phases.
Update for Swift 4:
Also the call is:
Edit: the collection in mac doesn't inherit from scrollview. updated properly