Scrolling an NSTextView

Discussion in 'Mac Programming' started by Soulstorm, Jul 7, 2008.

  1. Soulstorm macrumors 68000

    Soulstorm

    Joined:
    Feb 1, 2005
    #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?
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    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 :)
     
  3. CaptainZap macrumors regular

    Joined:
    Jan 17, 2007
    #4
    This might not be the most effective but I use it and it works
    Code:
    [textView scrollRangeToVisible: NSMakeRange ([[textView string] length], 0)];
     
  4. Soulstorm thread starter macrumors 68000

    Soulstorm

    Joined:
    Feb 1, 2005
    #5
    Thanks. That worked out quite nicely.

    I tried that, but I just seemed not to be able to find that particular NSClipView.
     

Share This Page