Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Soulstorm

macrumors 68000
Original poster
Feb 1, 2005
1,887
1
How can I scroll down programatically an NSTextView? My purpose is to make a text view scroll down as I add more things to the text view without any user interaction.

Any ideas?
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
You can't. NSTextViews don't scroll. Scrollable NSTextViews as dragged in IB are actually 3 views: An NSScrollView contains an NSClipView contains an NSTextView.

Scroll the NSClipView via scrollToPoint: then update the scrollbars of the NSScrollView with reflectScrolledClipView:.

I'm sure you knew that already :)
 

CaptainZap

macrumors regular
Jan 17, 2007
170
0
This might not be the most effective but I use it and it works
Code:
[textView scrollRangeToVisible: NSMakeRange ([[textView string] length], 0)];
 

Soulstorm

macrumors 68000
Original poster
Feb 1, 2005
1,887
1
This might not be the most effective but I use it and it works
Code:
[textView scrollRangeToVisible: NSMakeRange ([[textView string] length], 0)];

Thanks. That worked out quite nicely.

You can't. NSTextViews don't scroll. Scrollable NSTextViews as dragged in IB are actually 3 views: An NSScrollView contains an NSClipView contains an NSTextView.

I tried that, but I just seemed not to be able to find that particular NSClipView.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.