Re: Why would scroll events not arrive?
Re: Why would scroll events not arrive?
- Subject: Re: Why would scroll events not arrive?
- From: Martin Wierschin <email@hidden>
- Date: Mon, 29 Jun 2015 16:24:13 -0700
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 (email@hidden)
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:
This email sent to email@hidden