PROBLEM:
I have an NSScrollView. I use it to implement a custom "table view" with rows of data that are actually NSView. (Note: this is not an instance of NSTableView.)
When I scroll vertically (no horizontal scroll), I use the boundsChanged notification to add (as subviews of the scroll content of the ViewView) NSViews that become visible (those that have frames that intersect the scrollView document visible rect) and delete those that no longer visible (frames outside the scrollView visible rectangle).
The process works wonderfully, except when it comes to inertial scrolling. If I have a pointer to cell X, and I clicked the trackpad to scroll down FAST by inertia, cell X quickly leaves the visible rectangle and, as such, is removed from the scroll viewView. BUT that kills inertial scrolling. If I DO NOT delete cell X as a subview, then inertial scrolling works fine.
WHAT I NEED:
A way to save inertial scrolling when deleting an NSView when the cursor is higher than when the user started the scroll gesture.
WHAT I GOT:
I looked at the NSResponder method:
-scrollWheel:(NSEvent *)theEvent
The default implementation passes scrollWheel to the next responder. Thus, I have subclassed NSScrollView and implemented this method to try to stop it from passing the scrollWheel event to individual sub-objects in the scroll viewview. Does not work.
So, I went into my NSViews (the ones I add to the contentView) and rewind scrollWheel to pass the event back to scrollView itself. Does not work.
I still get scrolling in both cases, but not with inertia.
Any ideas? Thanks!
Bryan source share