• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Why would scroll events not arrive?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Why would scroll events not arrive? (From: Martin Wierschin <email@hidden>)
 >Re: Why would scroll events not arrive? (From: Ken Thomases <email@hidden>)
 >Re: Why would scroll events not arrive? (From: Martin Wierschin <email@hidden>)

  • Prev by Date: Re: Simple Swift question
  • Next by Date: Re: Simple Swift question
  • Previous by thread: Re: Why would scroll events not arrive?
  • Next by thread: Re: Why would scroll events not arrive?
  • Index(es):
    • Date
    • Thread