NSTextView

  • On an NSTextView I call -selectAll: and then -insertText:

    This scrolls the view to the end of the text.

    How would I scroll the view to the top of the text?

    -koko
  • On 07/06/2012, at 1:47 PM, koko wrote:

    > How would I scroll the view to the top of the text?

    [NSView scrollToPoint:<thePoint calculated from the zeroth character of the text>];

    --Graham
  • Got it …

        [m_clipView scrollToPoint:m_origin];
        [m_scrollView reflectScrolledClipView:m_clipView];

    -koko

    On Jun 6, 2012, at 9:47 PM, koko wrote:

    > On an NSTextView I call -selectAll: and then -insertText:
    >
    > This scrolls the view to the end of the text.
    >
    > How would I scroll the view to the top of the text?
    >
    > -koko
    >
  • On 07/06/2012, at 2:00 PM, koko wrote:

    > Got it …
    >
    > [m_clipView scrollToPoint:m_origin];
    > [m_scrollView reflectScrolledClipView:m_clipView];

    No you haven't. Look at what NSTextView inherits.....

    Actually, there is a method in NSText which is more direct - [NSText scrollRangeToVisible:];

    --Graham
  • On Thu, Jun 7, 2012 at 5:47 AM, koko <koko...> wrote:

    > On an NSTextView I call -selectAll: and then -insertText:
    >
    > This scrolls the view to the end of the text.
    >
    > How would I scroll the view to the top of the text?
    >

    Just before the insertText: get the current scroll position and then
    restore it:

    http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/NSSc
    rollViewGuide/Articles/Scrolling.html

    "Determining the Current Scroll Location"
previous month june 2012 next month
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  
Go to today