GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

"autoscroll down" for a textview scrolls up immedi

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
balance



Joined: 10 Mar 2008
Posts: 1

PostPosted: Mon Mar 10, 2008 3:50 pm    Post subject: "autoscroll down" for a textview scrolls up immedi Reply with quote

Hi,

the GtkTextView is initialized with:

Code: (C++)
1
2
3
4
5
6
7
8
9
10
11
12
pOutputView = gtk_text_view_new();
gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(pOutputView), GTK_TEXT_WINDOW_TEXT, 1);
gtk_text_view_set_editable(GTK_TEXT_VIEW(pOutputView), false);

pOutputWindow = gtk_scrolled_window_new( NULL, NULL);

gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(pOutputWindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);

gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(pOutputWindow), pOutputView);

pOutputBuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(pOutputView));


After a line is written to the buffer the view should scroll down with:

Code: (C++)
1
2
3
4
5
6
7
8
9
10
GtkTextIter    iterEnd;
gtk_text_buffer_get_end_iter(pOutputBuffer, &iterEnd);
gtk_text_buffer_insert(pOutputBuffer, &iterEnd, szOutput, -1);
   
// scroll down
gtk_text_buffer_get_end_iter(pOutputBuffer, &iterEnd);
GtkTextMark    *pMarkEnd = gtk_text_buffer_get_mark(pOutputBuffer, MARK_END_NAME);
gtk_text_buffer_move_mark(pOutputBuffer, pMarkEnd, &iterEnd);
gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(pOutputView), pMarkEnd, 0, false, 0, 0);


... but it doesn't work. I can see that the view is scrolling down for milliseconds and then poping back to the top of the buffer again.

Any suggestion?

Regards,
R

ps: the gtk version is 2.6.10
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP