On Jan 20, 2012, at 7:33 AM, Jerry Krinock wrote:

> I've bound the 'Attributed String' of an NSTextView.  This view a detail 
> view; its text changes whenever the user changes the selection in an 
> associated table.  Upon changing, the text scrolls to the bottom.  I want it 
> to stay at the top.
> 
> I understand that I can scroll back to the top by sending -scrollPoint:, 
> -scrollRectToVisible:, or -scrollRangeToVisible:, but where would I do this?  
> Invoking -performSelector:withObject:afterDelay: at then end of the getter 
> would probably work, but it seems like such a simple programming requirement 
> should not require such a kludge.  Bindings are supposed to make my life 
> easier!

While your switch away from bindings is fine and I won't discourage it, there's 
a simple solution to this issue.

The insight is that scrolling to the top isn't about a change in the bound key 
path.  It's about the change in selection.  For example, if the selection 
didn't change but the model value that the text view was showing did, would you 
want it to scroll to the top?  What if the text view is editable?  Should edits 
change the scroll position?  I would say no.  The desired scroll-to-top 
behavior is not tied to the value changing, it's tied to the selection changing.

So, when I've had a similar GUI, I simply invoke one of the -scroll... methods 
in the -tableViewSelectionDidChange: table view delegate method.

Regards,
Ken


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to