Re: GtkTreeView - Selecting the first row



Hannes Mayr wrote:
Stefan Kost wrote:

hi,

just a wild guess, are use using the GTK_SELECTION_BROWSE selection mode?

GtkTreeSelection *select;

select = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
gtk_tree_selection_set_mode (select, GTK_SELECTION_BROWSE);


Yes, I already tried that without success. I've found out, that the problem is the focus of the widget. When my app starts, another widget seems to have the focus and pressing tab or a cursor key moves the focus to the TreeView and the selection works.
So, my new questions is: How can I set the focus on the TreeView?
gtk_widget_grab_focus(treeview) doesn't work.


In case someone else runs into the same problem, I've found a solution:
After setting the model to the treeview I call set_cursor, which sets the selection to the first row.

renderer = gtk_cell_renderer_text_new();
path = gtk_tree_path_new_from_string("0");
gtk_tree_view_set_cursor(GTK_TREE_VIEW(treeview), path, NULL, renderer);

The documentation says set_cursor is often followed by a gtk_widget_grab_focus(), but I can't see any effect if I call it or not.

Hannes




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