Re: Getting NSScrollView to ignore scrolling
Re: Getting NSScrollView to ignore scrolling
- Subject: Re: Getting NSScrollView to ignore scrolling
- From: Andy Lee <email@hidden>
- Date: Sun, 20 Feb 2011 03:17:47 -0500
On Feb 19, 2011, at 7:48 PM, Quincey Morris wrote:
> On Feb 19, 2011, at 16:25, Peter Lübke wrote:
>
>>> My question is this: how do I get the scroll view to ignore scrolling messages? The tables/scrollviews are sitting on views that are part of a homebrew collection view, and the scrolling "catches" on them, even though there's no scrolling to be done. The scroll view is taking the events, but there is nothing for them to do. I want to be able to scroll past the table using a scrollwheel or the trackpad without the scrolling action "catching."
>>>
>>
>> What do you mean with "scroll past the table"?
>
> I'm pretty sure the OP is talking specifically about scrolling with the scroll wheel. (It sounds like the individual table views in his view collection don't have scroll bars, and are sized to show all their content anyway.) In that case, the table views or scroll views are still responding the scroll wheel, which prevents the collection view itself from scrolling.
>
> I think the only way to fix this is to override the appropriate 'scrollWheel:' event method, and to pass the event on up the responder chain.
I have the same requirement as the OP: a scroll view that never needs to actually scroll, but which nevertheless eats scrollWheel: events, which keeps *its* containing scroll view from getting them. My solution was exactly as you describe. For the inner scroll view I use a subclass of NSScrollView that overrides scrollWheel: by sending scrollWheel: to its nextResponder, causing the outer scroll view to eventually get it. You can use IB to set the class of the inner scroll view to the subclass.
I wonder if this is worth a Radar: "If a scroll view doesn't actually do anything in response to a scrollWheel: event, it should forward the event to nextResponder." This seems to me to be what the responder chain is *for*.
I notice WebKit does the expected thing with nested scroll views (for example in a typical web mail window in Safari). This includes cases where the inner scroll view *can* scroll. I actually find this annoying. In *this* case I'd prefer the scroll wheel to stop dead at the top or bottom. It's a Fitt's Law kind of thing for me; I want to be able to scroll, scroll, scroll to the bottom of a list and not have to be careful about scrolling so much that I shift the whole window contents around. But maybe arguments could be made the other way.
Anyway, you can get whatever behavior you need by overriding scrollWheel:.
--Andy
_______________________________________________
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