Re: GtkTreeView get selected row AND column



Juan Pablo wrote:
Hi list!
I have a GtkTreeView and what I want to do is when the user is over an
editable cell, the editing begins automatically without having to press
enter. And the other thing that i want to do is that when the user is
over a cell on a certain column the cursor changes automatically to the
next (he cant edit that cell).

The GtkTreeView is a ticket editor, when the user is on the first
column, the editing should be started automatically so he puts a product
code, then when he press enter, the second column is filled with the description of the product wich has that code and the third column
should get the focus, where, again without having to press enter, he
inputs the amount and then it jumps to the first column on the next row.

This is why i need to know the row and column, so in the cursor_changed
signal i can decide to emmit start_editing or to pass the focus some
where else.

you can use gtk_tree_view_set_cursor() and gtk_tree_view_get_cursor().
I store the row number in my model for easy reference.

GtkTreePath *path;
GtkTreeViewColumn *column;
glong column_ix,row_ix;

gtk_tree_view_get_cursor(treeview,&path,&column);
if(path && column) {
  GtkTreeIter iter;

  if(gtk_tree_model_get_iter(treestore),&iter,path)) {
    GList *columns=gtk_tree_view_get_columns(treeview);

    column_ix=g_list_index(columns,(gpointer)column)-1;
    g_list_free(columns);
    gtk_tree_model_get(treestore,&iter,TABLE_POS,&row_ix,-1);
  }
}
if(path) gtk_tree_path_free(path);

printf("cursor at col/row = %d,%d\n",column_ix,row_ix);


If is any other way to do it, please! :D

Thanks all.


Saludos, Juan Pablo.

                
___________________________________ A tu celular ¿no le falta algo? Usá Yahoo! Messenger y Correo Yahoo! en tu teléfono celular. Más información en http://movil.yahoo.com.ar
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




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