Re: -enclosingScrollView returns nil when receiver is a descendant of the clip view
Re: -enclosingScrollView returns nil when receiver is a descendant of the clip view
- Subject: Re: -enclosingScrollView returns nil when receiver is a descendant of the clip view
- From: Kyle Sluder <email@hidden>
- Date: Fri, 25 Jun 2010 10:51:45 -0700
On Wed, Jun 23, 2010 at 12:26 PM, email@hidden
<email@hidden> wrote:
>
> On 23 Jun 2010, at 19:50, Kyle Sluder wrote:
>>
>> To describe it a bit more visually, here's a diagram of our view hierarchy:
>>
>> Scroll View
>> |- Clip View
>> |- Accessory view
>> |- Document view
>>
>> Calling -enclosingScrollView on the accessory view returns nil. I
>> believe that it should return the scroll view.
>>
>> One of the workarounds we're mulling over is to replace NSView's
>> implementation of -enclosingScrollView to return the scroll view if
>> the receiver is a descendant of the clip view. This makes sense to me,
>> because I can't see a situation in which one would call
>> -enclosingScrollView without the intent of obtaining "the scroll view
>> that is responsible for scrolling me around." But since we don't have
>> the source to AppKit, we can't be sure that AppKit doesn't rely on
>> this behavior.
>>
> Perhaps:
>
> Define a -scrollViewSibling property/outlet on the accessory view and point it to the document view.
>
> The NSView -enclosingScrollView override can check for a response to scrollViewSibling and
> conditionally send -enclosingScrollView to it.
>
> That way you are only overriding the -enclosingScrollView behaviour for views whose response is considered defective.
We're doing this now (actually, we can't use an outlet because this is
a view class in a framework, but the result is the same; we ask the
document view for its -enclosingScrollView).
I've also added a debug-only override of -[NSView enclosingScrollView]
to trap all occasions where someone calls -enclosingScrollView and it
returns nil, even though I think it should return an NSScrollView. It
turns out that one of the places this happens is when layer-backed
views set up their layers. I'm wondering if that has any bearing on
some of the bugs we've seen with layer-backed views in scroll views.
Perhaps the authors of that code harbored the same assumptions about
-enclosingScrollView that I did.
--Kyle Sluder
_______________________________________________
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