Re: Scrolling to "top" item in a treeview?



Rob Meyers wrote:

How would I go about scrolling to the top item in a table, where
the underlying data structure is a treeview?  I want to keep the
scroll view at the top of the table (items are sorted by relevance),
and when a new item appears above the current view, I want to scroll
up.

I've tried using 'scroll_to_row(TreeModel::Path("0")', but sometimes
this goes to the bottom row instead of the top.

I've also tried looking at the value of get_y() from get_cell_area()
of the first column in the new path.  In most cases, I get either
a value of 1, or a negative value, indicating the new row is above
the scrolled area.  In some cases though, get_y() will return 1, and
the new row is actually on the bottom, many rows below the scrolled
view.

Is there a better way to determine the relative position of a new
row?

Thanks,

Assuming your Gtk::TreeView * is "tree" do this:

tree->set_cursor(Gtk::TreeModel::Path("0"));

at the appropriate time.

Bob Caryl



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