Re: How to make scroll bars follow text



David,

I couldn't find an automatic way of doing it but it's fairly simple to
manually scroll every time you insert some text.

You need a "GtkTextMark" at the end of the buffer which you can get (once)
with:

    GtkTextIter startIter, endIter;
    GtkTextMark *endMark;

    gtk_text_buffer_get_bounds(textBuffer, &startIter, &endIter);
    endMark = gtk_text_buffer_create_mark(textBuffer, NULL, &end, FALSE);

(assuming "textBuffer" is a "GtkTextBuffer *").

Then, after every insert, manually cause a scroll with:

    gtk_text_view_scroll_mark_onscreen(textView, endMark);

(where textView is the result of your gtk_text_view_new() call).

There are alternative scrolling functions described in the documentation
which allow you to specify the location on screen and so on if you need it.

All the above assumes GTK+ V2 by the way.

Regards,
Richard.

----- Original Message -----
From: "David Shifflett" <shifflett nps navy mil>
To: <gtk-app-devel-list gnome org>
Sent: Friday, September 20, 2002 10:12 PM
Subject: How to make scroll bars follow text


Hi,
I am using a scrolled window and want to know how to
automatically make the scrollbar (vertical only)
position itself such that last item inserted into
the text field (within the scrolled window) is always
visible at the bottom of the scrolled window.

To put it another way:
The scrolled window shows 10 lines of text at a time.
once the text widget has more than 10 lines in it,
the bottom ten lines should be visible whenever new
text is added to the text widget.

Once the text widget is completely full (say 100 lines)
and I put the scrollbar all the way down manually,
the scrollbar will always show the last text inserted.

How do I make this behavior the default, even before
the text widget is full?

Any help, comments, examples, would be appreciated
Thanks,
David Shifflett





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]