Re: Expanding NSScrollView
Re: Expanding NSScrollView
- Subject: Re: Expanding NSScrollView
- From: Andrew Shamel <email@hidden>
- Date: Sun, 26 Jul 2009 10:11:25 -0600
Thanks so much for your help! I got this to work beautifully, the
only problem is that I can't now get the scrollview (or its enclosing
view, etc.) to shrink back when the text/rows get shorter, since the
frame of the documentView does not seem to get smaller as the text
recedes (I haven't tried it with a table yet). The notification stops
being sent, since the documentView and contentView seem to stop
changing size.
Any thoughts?
Thanks again.
Peace,
Andy Shamel
On 21 Jul 2009, at 3:51 PM, Quincey Morris wrote:
Ack! That seems far too complicated.
You can have your window controller (or whatever equivalent
controller you're using) register via
'addObserver:selector:name:object:' to be notified when the
NSTextView or NSTableView frame changes. (Note that you have to call
'setPostsFrameChangedNotifications:YES' on those views to be able to
get these notifications.)
When you get a notification, compare the frame of the NSTextView or
NSTableView with the bounds of the scroll view's clip view (the
documentView frame and the clipView bounds are in the same
coordinate system) to determine whether the clip view is too big,
too small or just right.
If the clip view is the wrong size, you need to resize the view
containing the scroll view (so that the things adjacent to the
scroll view move out of its way) by the amount that the clip view is
wrong. Autoresizing should then trickle down and produce the results
you want.
There are a few things to be careful of:
-- resizing view while you're in the notification handler method may
cause additional notifications, and you need to handle that
-- if you want the number of line/rows to change for other reasons
(e.g. when you resize the window), you might have to observe the
clip view frame too
-- if you have autohiding vertical scroll bars on you NSTextView or
NSTableView, you may end up in a situation where the scroll view
size change "bounces" up and down, and you need to handle that
HTH
_______________________________________________
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