• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTextView : Scroll top when bound-to string changes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextView : Scroll top when bound-to string changes


  • Subject: Re: NSTextView : Scroll top when bound-to string changes
  • From: Ken Thomases <email@hidden>
  • Date: Sun, 22 Jan 2012 13:44:50 -0600

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 (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


References: 
 >NSTextView : Scroll top when bound-to string changes (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: NSXMLParser, streams, multiple threads, and crashing
  • Next by Date: Re: While running our iPhone app, the screen sometimes goes white and locks up. Any idea why?
  • Previous by thread: Re: NSTextView : Scroll top when bound-to string changes
  • Next by thread: While running our iPhone app, the screen sometimes goes white and locks up. Any idea why?
  • Index(es):
    • Date
    • Thread