Re: [NSView noob] How to be detect when a scroll view scrolls its document view
Re: [NSView noob] How to be detect when a scroll view scrolls its document view
- Subject: Re: [NSView noob] How to be detect when a scroll view scrolls its document view
- From: Graham Cox <email@hidden>
- Date: Wed, 1 Apr 2009 12:13:13 +1100
On 01/04/2009, at 10:01 AM, Stuart Malin wrote:
I have an NSScrollView with a document view that contains many
subviews. I need to perform some processing on these views as they
become visible or not visible because of scrolling of the
ScrollView. I'm sure this must be straightforward to detect, but
alas, I don't have a deep enough understanding of Views and
ClipViews and ScrollViews. I've looked at the Cocoa Views Guide, and
pertinent class documentation, but the requisite means have not been
obvious to me. I've looked either for some kind of notification to
register for, or a method to override. I have tried registering for
the NSViewFramDidChangeNotification of the scroll view's clipView,
but seem to only receive that on a resize, and not on scrolling. I
suspect what I need to know is when the documentVisibleRect (or
visibleRect) changes... I'd appreciate any pointers regarding what I
should be looking at to devise a solution. TIA.
You're overthinking this.
-drawRect: will be called with the area needing update, as it is
revealed by scrolling. You can then just draw what intersects that
rect, or use -needsToDrawRect:
For embedded subviews, -drawRect: isn't even called if no part of the
view is visible.
--Graham
_______________________________________________
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