Scrolling a NSScrollView to the bottom

Ask a Question related to Mac Programming, Design and Development.

  1. #1

    Default Re: Scrolling a NSScrollView to the bottom

    In <hraftery-2FB90A.21082003082003@seagoon.newcastle.edu.au> Heath
    Raftery wrote:
    > I've embeded a NSScrollView in my app, which is filled with the
    > contents of a text file. This text file is typically large, and I
    > want to have the scroller at the bottom by default. Here's what I'm
    > using at present:
    >
    > NSPoint bottomOfDocument = {0, 9999999};
    > bottomOfDocument = [[sMessages contentView]
    > constrainScrollPoint:bottomOfDocument];
    > [[sMessages contentView] scrollToPoint:bottomOfDocument];
    >
    > This works, however the scroller position widget (the blue/graphite
    > glob in the scroller) remains at the top, when the tabview with the
    > NSScollView is made visible. It goes immediately to the bottom if the
    > scroller's up arrow is clicked, but on first glance it is not obvious
    > that the bottom of the file is being shown.
    >
    > Any suggestions on getting the widget to update, or a cleaner way of
    > doing same?
    reflectScrolledClipView. But, you shouldn't be bossing the clipView
    around this way; leave it alone and let it do its job. It's the
    documentView you want to move. I take it you are saying you've got an
    NSTextView, so scrollRangeToVisible is an easy reliable way to scroll it,
    or you can use any of a number of NSView commands. Basically it's just a
    matter of RTFM. m.

    --
    matt neuburg, phd = [email]matt@tidbits.com[/email], [url]http://www.tidbits.com/matt[/url]
    REALbasic: The Definitive Guide! 2nd edition!
    [url]http://www.amazon.com/exec/obidos/ASIN/0596001770/somethingsbymatt[/url]
    Subscribe to TidBITS. It's free and smart.
    matt neuburg Guest

  2. Similar Questions and Discussions

    1. Top/Bottom scrolling of table
      Hello, I am trying to have the content inside of my table scroll top to bottom. Does any one know how to solve this issue. Here is the code for...
    2. Scroll Bar at bottom
      I'm using a frame set and have a scroll bar at the bottom of the page I dont want. I assume this has to do with the page fitting into the browser. ...
    3. combination scrolling text scrolling picture and on MouseEnter function
      it would help if you posted the code for us to look at... that way we can try to help ;) In article <bk6jip$ctm$1@forums.macromedia.com>, <...
    4. Custom Scroll Bar: Want to switch scrolling member, but keep scrolling intact.
      Hey all. This is a juicy one. Simple Idea, Simple minded author can't find solution.... I have a text member in sprite 29. I have the "Custom...
    5. NSScrollView for NSTextView scrolls then snaps back
      I have a text view created in IB that I use to display the contents of the clipboard by doing a paste into the text view. When the text is...
  3. #2

    Default Re: Scrolling a NSScrollView to the bottom

    In article <20030803092849227-0700@news.la.sbcglobal.net>,
    matt neuburg <matt@tidbits.com> wrote:
    > In <hraftery-2FB90A.21082003082003@seagoon.newcastle.edu.au> Heath
    > Raftery wrote:
    > > I've embeded a NSScrollView in my app, which is filled with the
    > > contents of a text file. This text file is typically large, and I
    > > want to have the scroller at the bottom by default. Here's what I'm
    > > using at present:
    > >
    > > NSPoint bottomOfDocument = {0, 9999999};
    > > bottomOfDocument = [[sMessages contentView]
    > > constrainScrollPoint:bottomOfDocument];
    > > [[sMessages contentView] scrollToPoint:bottomOfDocument];
    > >
    > > This works, however the scroller position widget (the blue/graphite
    > > glob in the scroller) remains at the top, when the tabview with the
    > > NSScollView is made visible. It goes immediately to the bottom if the
    > > scroller's up arrow is clicked, but on first glance it is not obvious
    > > that the bottom of the file is being shown.
    > >
    > > Any suggestions on getting the widget to update, or a cleaner way of
    > > doing same?
    >
    > reflectScrolledClipView. But, you shouldn't be bossing the clipView
    > around this way; leave it alone and let it do its job. It's the
    > documentView you want to move. I take it you are saying you've got an
    > NSTextView, so scrollRangeToVisible is an easy reliable way to scroll it,
    > or you can use any of a number of NSView commands. Basically it's just a
    > matter of RTFM. m.
    Thanks for the suggestions Matt. I'd had tried a few
    reflectScrolledClipView's in the meantime without success. Even with
    your suggestions I was unable to get it working tonight, but that could
    be put down to lack of sleep at this stage. I think what you've
    demonstrated is what I always felt - I really don't understand the MVC
    relationship well enough to do this stuff comfortably. I'll be taking
    your advice by reading a few docs.

    I've been working through O'Reilly's Building Cocoa Applications and
    Apple Cocoa NSView etc. docs, without too many lightbulbs turning on
    unfortunately. I guess, even though I am aware of the differences
    between RAD and an environment like PB/IB, that I am still expecting
    immediate results like I can achieve with Delphi and Borland C++ Builder.

    Don't suppose you have any more specific suggestions on how someone, who
    is quite confident programming in procedural and object-orientated
    environments, can unravel the
    NSView/NSTextView/NSClipView/NSDocumentView/NSScrollView paradigm?

    Cheers,
    Heath

    --
    Heath
    __________________________________________________ ______
    | *Nothing is foolproof to a sufficiently talented fool* |
    | _\|/_ |
    |________________________________________m(. .)m_________|
    Heath Raftery Guest

  4. #3

    Default Re: Scrolling a NSScrollView to the bottom

    In <hraftery-7214B3.00483005082003@seagoon.newcastle.edu.au> Heath
    Raftery wrote:
    > Don't suppose you have any more specific suggestions on how someone,
    > who is quite confident programming in procedural and object-
    > orientated environments, can unravel the NSView/NSTextView/
    > NSClipView/NSDocumentView/NSScrollView paradigm
    Actually I think the docs are very good. Always start with the topics.
    For example the TextArchitecture concept files are really great, and
    AboutScrollViews.html tells you about scroll views. Only then should you
    read the NS***.html file, and when you do, don't forget to look at the
    superclass right the way up the hierarchy. For example, beginners fail
    to look at NSText when they are thinking about NSTextView. m.


    --
    matt neuburg, phd = [email]matt@tidbits.com[/email], [url]http://www.tidbits.com/matt[/url]
    REALbasic: The Definitive Guide! 2nd edition!
    [url]http://www.amazon.com/exec/obidos/ASIN/0596001770/somethingsbymatt[/url]
    Subscribe to TidBITS. It's free and smart.
    matt neuburg Guest

  5. #4

    Default Re: Scrolling a NSScrollView to the bottom

    In article <20030804122130773-0700@news.la.sbcglobal.net>,
    matt neuburg <matt@tidbits.com> wrote:
    > In <hraftery-7214B3.00483005082003@seagoon.newcastle.edu.au> Heath
    > Raftery wrote:
    > > Don't suppose you have any more specific suggestions on how someone,
    > > who is quite confident programming in procedural and object-
    > > orientated environments, can unravel the NSView/NSTextView/
    > > NSClipView/NSDocumentView/NSScrollView paradigm
    >
    > Actually I think the docs are very good. Always start with the topics.
    > For example the TextArchitecture concept files are really great, and
    > AboutScrollViews.html tells you about scroll views. Only then should you
    > read the NS***.html file, and when you do, don't forget to look at the
    > superclass right the way up the hierarchy. For example, beginners fail
    > to look at NSText when they are thinking about NSTextView. m.
    Just a belated thank you note Matt. I've since got my scrollview
    happening nicely and have learnt quite a bit about the Cocoa
    documentation system and text architecture. It actually turned out that
    I had a logic error earlier in my program which was giving weird results
    in the scrolling and throwing me off. For those interested, the
    following works nicely:

    [tMessages setString:myString];

    myRange.location = [myString length];
    [tMessages scrollRangeToVisible:myRange];

    where tMessages is my IBOutlet NSTextView*.

    --
    Heath
    __________________________________________________ ______
    | *Nothing is foolproof to a sufficiently talented fool* |
    | _\|/_ |
    |________________________________________m(. .)m_________|
    Heath Raftery Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139