Re: Scroll view clip view not moving to new object inserted in contained NSCollectionView - when are resizing events in the view hierarchy complete?
Re: Scroll view clip view not moving to new object inserted in contained NSCollectionView - when are resizing events in the view hierarchy complete?
- Subject: Re: Scroll view clip view not moving to new object inserted in contained NSCollectionView - when are resizing events in the view hierarchy complete?
- From: Luke Evans <email@hidden>
- Date: Wed, 16 Jan 2008 15:54:08 -0800
Hi Kyle,
Thanks.
I see the docs on NSView notifications indeed say:
An NSView instance that bases its own display on the layout of its
subviews should register itself as an observer for those subviews and
update itself any time they’re moved or resized. Both NSScrollView and
NSClipView instances cooperate in this manner to adjust the scroll
view's scrollers.
In fact, I do have a subclass of NSCollectionView I'm working with
(just to control the loading of item NIBs at the moment), and I could
have this object (representing a strip) register for its own frame
change notifications (...it seems odd to me how it doesn't get a
message to inform itself of these changes by default, but I'm new to
the Cocoa philosophy, so guess that must make some kind of sense).
With such a change though, I'll be left scrabbling to find which of my
tiles is actually the new one (the tiles know this of course, but the
NSCollectionView they happen to be in would have to enumerate its
contents to find the tile that has just been added - and hence lives
at the right-hand end of the strip). It may be better to have ALL the
tiles register for such changes to their container's frame size, and
then the right-most (newly added one) can respond by doing the
scrollRectToVisible with its own bounds.
I'm sure this would work, but I'm surprised there isn't a better way
(i.e. without adding plumbing that requires prior knowledge of other
instances in the view hierarchy to work) to know when your superviews
should be in state that fully represents your own existence and hence
a time when such a call could be made.
--Lwe
On 16-Jan-08, at 2:47 PM, Kyle Sluder wrote:
If I'm not mistaken, NSScrollView (or NSClipView) registers for the
document view's NSViewFrameDidChangeNotification, which is going to
happen in the next run through the runloop after your view gets added
to the NSCollectionView. Perhaps you should have a controller of some
sort register for this notification from the collection view as well
and have that object scroll the scroll view by calling
-[NSCollectionView scrollRectToVisible:].
HTH,
--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