After further investigation, I've discovered what code is responsible for 
globally breaking scrolling my app. I have an NSScrollView subclass with the 
following override:

- (void) scrollWheel:(NSEvent*)event
{
        BOOL isScrollEnclosing = // YES if the receiver has scrolled to its 
very top/bottom
        if( isScrollEnclosing ) {
                [[self enclosingScrollView] scrollWheel:event];
        }
        else {
                [super scrollWheel:event];
        }
}

I'm not sure the code is breaking any rules, but it apparently intermittently 
rubs AppKit the wrong way. At least if the user has a multi-touch trackpad. 
Macs with older trackpads (or just mice) seem to be unaffected.

Using the following code instead avoids the problem and still achieves the 
desired behavior:

- (void) scrollWheel:(NSEvent*)event
{
        BOOL isScrollEnclosing = // YES if the receiver has scrolled to its 
very top/bottom
        if( isScrollEnclosing ) {
                CGEventRef cgEvent = CGEventCreateScrollWheelEvent( ... );
                if( NULL != cgEvent ) {
                        NSEvent* fakeEvent = [NSEvent eventWithCGEvent:cgEvent];
                        [[self enclosingScrollView] scrollWheel:fakeEvent];
                        CFRelease(cgEvent);
                }
        }
        [super scrollWheel:event];
}

I’m posting this on the off-chance it might be helpful to someone else down the 
line.

~Martin Wierschin


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to