• 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: Automatic scrolling in an NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Automatic scrolling in an NSTextView


  • Subject: Re: Automatic scrolling in an NSTextView
  • From: Scott Anguish <email@hidden>
  • Date: Mon, 14 Oct 2002 00:10:01 -0400

On Sunday, October 13, 2002, at 11:57 PM, Mike Brinkman wrote:

I've got an NSMutableString which I append and then set as the string in an NSTextView as such:

[myText setString:myString];

It works like a charm, except that I have to scroll to see the appended text. Is there a way to have the NSTextView scroll automatically to the most recently appended text?


Well, it's actually never going to know which text has been appended, since you add are replacing the full text each time.

I prefer

stringRepresentation=[stringToAppend stringByAppendingString:@"\n"];
NSRange insertAtEnd=NSMakeRange([[myText textStorage] length],0);
[myText replaceCharactersInRange:insertAtEnd withString:stringRepresentation];
[myText scrollRangeToVisible:insertAtEnd];

Note the line at the end will scroll the text to the end..
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
References: 
 >Automatic scrolling in an NSTextView (From: Mike Brinkman <email@hidden>)

  • Prev by Date: Automatic scrolling in an NSTextView
  • Next by Date: Re: contextual menus in finder / cocoa & carbon integration
  • Previous by thread: Automatic scrolling in an NSTextView
  • Next by thread: Inline editing in NSTableViews
  • Index(es):
    • Date
    • Thread